snapshot
This commit is contained in:
parent
47036cde64
commit
0968b6f955
57 changed files with 426 additions and 86 deletions
59
lib.nix
59
lib.nix
|
@ -13,4 +13,63 @@ lib: _: {
|
|||
host,
|
||||
port,
|
||||
}: "${host}:${builtins.toString port}";
|
||||
|
||||
mkSecrets = secrets: let
|
||||
mkSecret = {
|
||||
name,
|
||||
secret,
|
||||
}:
|
||||
secret
|
||||
// {
|
||||
file = ./secrets/${name}.age;
|
||||
};
|
||||
in
|
||||
builtins.mapAttrs (name: secret: mkSecret {inherit name secret;}) secrets;
|
||||
|
||||
genNixosConfigurations = {
|
||||
inputs,
|
||||
extraModules,
|
||||
}: let
|
||||
commonDir = ./common;
|
||||
classesDir = ./classes;
|
||||
hostsDir = ./hosts;
|
||||
|
||||
commonNixosSystem = {
|
||||
class,
|
||||
name,
|
||||
}:
|
||||
lib.nixosSystem {
|
||||
specialArgs = {
|
||||
inherit inputs lib;
|
||||
attrName = name;
|
||||
};
|
||||
|
||||
modules =
|
||||
(lib.findModules [
|
||||
commonDir
|
||||
./classes/${class}
|
||||
(classesDir + "/${class}")
|
||||
(hostsDir + "/${class}/${name}")
|
||||
])
|
||||
++ [
|
||||
{networking.hostName = lib.mkDefault name;}
|
||||
]
|
||||
++ extraModules;
|
||||
};
|
||||
|
||||
dirsIn = dir:
|
||||
lib.pipe (builtins.readDir dir) [
|
||||
(lib.filterAttrs (_: type: type == "directory"))
|
||||
builtins.attrNames
|
||||
];
|
||||
in
|
||||
lib.pipe (dirsIn hostsDir) [
|
||||
(classes:
|
||||
builtins.concatMap (
|
||||
class: map (name: {inherit class name;}) (dirsIn (hostsDir + "/${class}"))
|
||||
)
|
||||
classes)
|
||||
(map (obj: lib.nameValuePair obj.name (commonNixosSystem obj)))
|
||||
builtins.listToAttrs
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue