clan: Add autoloaded clanModules from flake inputs. Rename 'directory' to 'self' in buildClan

This commit is contained in:
Qubasa
2025-01-24 12:32:04 +07:00
parent 83c6ad19eb
commit ed6aaf5f0c
14 changed files with 70 additions and 33 deletions

View File

@@ -8,7 +8,8 @@
}:
{
## Inputs
directory, # The directory containing the machines subdirectory # allows to include machine-specific modules i.e. machines.${name} = { ... }
directory ? null, # The directory containing the machines subdirectory # allows to include machine-specific modules i.e. machines.${name} = { ... }
self ? null,
# A map from arch to pkgs, if specified this nixpkgs will be only imported once for each system.
# This improves performance, but all nipxkgs.* options will be ignored.
# deadnix: skip
@@ -19,15 +20,27 @@
...
}@attrs:
let
eval = import ./eval.nix {
evalUnchecked = import ./eval.nix {
inherit
lib
nixpkgs
specialArgs
clan-core
;
self = directory;
inherit specialArgs;
self = if self != null then self else directory;
};
# Doing `self ? lib.trace "please use self" directory`, doesn't work
# as when both (directory and self) are set we get an infinite recursion error
eval =
if directory == null && self == null then
throw "The buildClan function requires argument 'self' to be set"
else if directory != null && self != null then
throw "Both 'self' and 'directory' are set, please remove 'directory' in favor of the 'self' argument"
else if directory != null then
lib.warn "The 'directory' argument in buildClan has been deprecated in favor of the 'self' argument" evalUnchecked
else
evalUnchecked;
rest = builtins.removeAttrs attrs [ "specialArgs" ];
in
eval {
@@ -35,5 +48,6 @@ eval {
rest
# implementation
./module.nix
./auto-imports.nix
];
}