From e195a77476c47f08d5ebeb7e769c144ac76eab4f Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 26 Jun 2025 17:08:20 +0200 Subject: [PATCH] buildClan: deprecate in favor of 'clan' clan.lib.clan { } returns an eval result In contrast to buildClan which returns the .config This allows for better introspection --- lib/default.nix | 1 + lib/modules/default.nix | 75 ++++++++++------------------------------- lib/modules/tests.nix | 32 +++++++++--------- 3 files changed, 35 insertions(+), 73 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index 4d001e913..6748173bb 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -22,6 +22,7 @@ lib.fix ( inherit (buildClanLib) buildClan + clan ; /** Like callPackage, but doesn't try to automatically detect arguments diff --git a/lib/modules/default.nix b/lib/modules/default.nix index 37ded431a..2600fab0e 100644 --- a/lib/modules/default.nix +++ b/lib/modules/default.nix @@ -1,6 +1,5 @@ ## WARNING: Do not add core logic here. -## This is only a wrapper such that buildClan can be called as a function. -## Add any logic to ./module.nix +## This is only a wrapper such that 'clan' can be called as a function. { lib, clanLib, @@ -9,65 +8,27 @@ nix-darwin, }: rec { - # ------------------------------------ - buildClan = buildClanWith { - inherit - clan-core - nixpkgs - nix-darwin - ; - }; - /** - A function that takes some arguments such as 'clan-core' and returns the 'buildClan' function. + buildClan = + module: lib.warn "'buildClan' is deprecated. Use 'clan-core.lib.clan' instead" (clan module).config; - # Arguments of the first function - - clan-core: Self, provided by our flake-parts module - - publicAttrs: { clan :: List Str, topLevel :: List Str } Publicly exported attribute names - - # Arguments of the second function (aka 'buildClan') - - self: Reference to the users flake - - inventory: An "Inventory" attribute set, see the docs, for how to construct one - - specialArgs: Extra arguments to pass to nixosSystem i.e. useful to make self available - - ...: Any other argument of the 'clan' submodule. See the docs for all available options - - # Returns - - Public attributes of buildClan. As specified in publicAttrs. - */ - buildClanWith = + clan = { - clan-core, - # TODO: Below should be module options such that the user can override them? - nixpkgs, - nix-darwin ? null, - }: - { - ## Inputs self ? lib.warn "Argument: 'self' must be set when using 'buildClan'." null, # Reference to the current flake - specialArgs ? { }, # Extra arguments to pass to nixosSystem i.e. useful to make self available ... }@m: - let - result = lib.evalModules { - specialArgs = { - inherit (clan-core) clanLib; - inherit - self - clan-core - nixpkgs - nix-darwin - ; - }; - modules = [ - # buildClan arguments are equivalent to specifying a module - m - clanLib.module - ]; + lib.evalModules { + specialArgs = { + inherit (clan-core) clanLib; + inherit + self + clan-core + nixpkgs + nix-darwin + ; }; - in - # Remove result.config in 26. July - result - // (lib.mapAttrs ( - n: v: lib.warn "buildClan output: Use 'config.${n}' instead of '${n}'" v - ) result.config); + modules = [ + m + clan-core.modules.clan.default + ]; + }; } diff --git a/lib/modules/tests.nix b/lib/modules/tests.nix index d8991e510..fc5f23700 100644 --- a/lib/modules/tests.nix +++ b/lib/modules/tests.nix @@ -9,13 +9,13 @@ let _acc: _name: value: lib.seq value true ) true; - inherit (clan-core.clanLib) buildClan; + inherit (clan-core.clanLib) clan; in ####### { test_missing_self = let - eval = buildClan { + eval = clan { meta.name = "test"; directory = ./.; }; @@ -27,7 +27,7 @@ in test_only_required = let - eval = buildClan { + eval = clan { self = { inputs = { }; outPath = ./.; @@ -42,7 +42,7 @@ in test_all_simple = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -60,7 +60,7 @@ in test_outputs_clanInternals = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -86,7 +86,7 @@ in test_fn_simple = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -101,7 +101,7 @@ in test_fn_clan_core = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -119,7 +119,7 @@ in test_machines_are_modules = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -135,9 +135,9 @@ in ]; }; - test_buildClan_all_machines = + test_clan_all_machines = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -156,9 +156,9 @@ in ]; }; - test_buildClan_specialArgs = + test_clan_specialArgs = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -178,9 +178,9 @@ in expected = "dream2nix"; }; - test_buildClan_darwin_machines = + test_clan_darwin_machines = let - eval = buildClan { + eval = clan { self = { inputs = { }; }; @@ -211,9 +211,9 @@ in }; }; - test_buildClan_all_machines_laziness = + test_clan_all_machines_laziness = let - eval = buildClan { + eval = clan { self = { inputs = { }; };