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 0271af0dcb
commit e195a77476
3 changed files with 35 additions and 73 deletions

View File

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

View File

@@ -1,6 +1,5 @@
## WARNING: Do not add core logic here. ## WARNING: Do not add core logic here.
## This is only a wrapper such that buildClan can be called as a function. ## This is only a wrapper such that 'clan' can be called as a function.
## Add any logic to ./module.nix
{ {
lib, lib,
clanLib, clanLib,
@@ -9,46 +8,15 @@
nix-darwin, nix-darwin,
}: }:
rec { rec {
# ------------------------------------ buildClan =
buildClan = buildClanWith { module: lib.warn "'buildClan' is deprecated. Use 'clan-core.lib.clan' instead" (clan module).config;
inherit
clan-core
nixpkgs
nix-darwin
;
};
/**
A function that takes some arguments such as 'clan-core' and returns the 'buildClan' function.
# Arguments of the first function clan =
- 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-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 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: }@m:
let lib.evalModules {
result = lib.evalModules {
specialArgs = { specialArgs = {
inherit (clan-core) clanLib; inherit (clan-core) clanLib;
inherit inherit
@@ -59,15 +27,8 @@ rec {
; ;
}; };
modules = [ modules = [
# buildClan arguments are equivalent to specifying a module
m m
clanLib.module clan-core.modules.clan.default
]; ];
}; };
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);
} }

View File

@@ -9,13 +9,13 @@ let
_acc: _name: value: _acc: _name: value:
lib.seq value true lib.seq value true
) true; ) true;
inherit (clan-core.clanLib) buildClan; inherit (clan-core.clanLib) clan;
in in
####### #######
{ {
test_missing_self = test_missing_self =
let let
eval = buildClan { eval = clan {
meta.name = "test"; meta.name = "test";
directory = ./.; directory = ./.;
}; };
@@ -27,7 +27,7 @@ in
test_only_required = test_only_required =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
outPath = ./.; outPath = ./.;
@@ -42,7 +42,7 @@ in
test_all_simple = test_all_simple =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -60,7 +60,7 @@ in
test_outputs_clanInternals = test_outputs_clanInternals =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -86,7 +86,7 @@ in
test_fn_simple = test_fn_simple =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -101,7 +101,7 @@ in
test_fn_clan_core = test_fn_clan_core =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -119,7 +119,7 @@ in
test_machines_are_modules = test_machines_are_modules =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -135,9 +135,9 @@ in
]; ];
}; };
test_buildClan_all_machines = test_clan_all_machines =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -156,9 +156,9 @@ in
]; ];
}; };
test_buildClan_specialArgs = test_clan_specialArgs =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -178,9 +178,9 @@ in
expected = "dream2nix"; expected = "dream2nix";
}; };
test_buildClan_darwin_machines = test_clan_darwin_machines =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -211,9 +211,9 @@ in
}; };
}; };
test_buildClan_all_machines_laziness = test_clan_all_machines_laziness =
let let
eval = buildClan { eval = clan {
self = { self = {
inputs = { }; inputs = { };
}; };