mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
feat(meta): support nixos builder
This commit is contained in:
parent
624f7f4a6f
commit
c009a78e33
2 changed files with 43 additions and 4 deletions
|
|
@ -5,14 +5,15 @@
|
|||
meta,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
}@metaArgs: let
|
||||
/*
|
||||
This module:
|
||||
* Makes hosts nixosModules.
|
||||
* Manages module imports and specialArgs.
|
||||
* Builds network.nodes.
|
||||
*/
|
||||
with lib; {
|
||||
enableNixosBuilder = false;
|
||||
in with lib; {
|
||||
options.network = {
|
||||
nixos = {
|
||||
extraModules = mkOption {
|
||||
|
|
@ -27,6 +28,9 @@ with lib; {
|
|||
type = types.path;
|
||||
default = toString (pkgs.path + "/nixos/modules");
|
||||
};
|
||||
builder = mkOption {
|
||||
type = types.unspecified;
|
||||
};
|
||||
};
|
||||
nodes = let
|
||||
nixosModule = {
|
||||
|
|
@ -79,7 +83,9 @@ with lib; {
|
|||
};
|
||||
in
|
||||
mkOption {
|
||||
type = types.attrsOf nixosType;
|
||||
type = types.lazyAttrsOf (
|
||||
if enableNixosBuilder then types.unspecified else nixosType
|
||||
);
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
|
@ -92,6 +98,35 @@ with lib; {
|
|||
inherit (config.network) nodes;
|
||||
inherit inputs meta pkgs;
|
||||
};
|
||||
builder = mkOptionDefault ({
|
||||
pkgs ? metaArgs.pkgs,
|
||||
system ? pkgs.system,
|
||||
lib ? if args ? pkgs then pkgs.lib else metaArgs.lib,
|
||||
nixosSystem ? import (pkgs.path + "/nixos/lib/eval-config.nix"),
|
||||
baseModules ? import (modulesPath + "/module-list.nix"),
|
||||
modulesPath ? toString (pkgs.path + "/nixos/modules"),
|
||||
specialArgs ? config.network.nixos.specialArgs,
|
||||
extraModules ? config.network.nixos.extraModules,
|
||||
imports ? [ ],
|
||||
name,
|
||||
...
|
||||
}@args: let
|
||||
args' = builtins.removeAttrs args [
|
||||
"extraModules" "specialArgs" "modulesPath" "baseModules" "lib" "pkgs" "system" "imports" "name"
|
||||
];
|
||||
c = nixosSystem ({
|
||||
inherit lib baseModules extraModules pkgs system;
|
||||
modules = imports;
|
||||
specialArgs =
|
||||
{
|
||||
inherit baseModules name;
|
||||
inherit (config.network.nixos) modulesPath;
|
||||
}
|
||||
// config.network.nixos.specialArgs;
|
||||
} // args');
|
||||
in if enableNixosBuilder then c.config else {
|
||||
inherit imports;
|
||||
});
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue