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

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