buildClan: deprecate in favor of 'clan'

clan.lib.clan { <your definition> } returns an eval result
In contrast to buildClan which returns the .config
This allows for better introspection
This commit is contained in:
Johannes Kirschbauer
2025-06-26 17:08:20 +02:00
parent f6de6632e4
commit a35e2d84d1
3 changed files with 35 additions and 73 deletions

View File

@@ -22,6 +22,7 @@ lib.fix (
inherit (buildClanLib)
buildClan
clan
;
/**
Like callPackage, but doesn't try to automatically detect arguments

View File

@@ -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
];
};
}

View File

@@ -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 = { };
};