2024-09-15 14:16:32 +02:00
|
|
|
lib: _: {
|
2025-01-04 23:51:35 +01:00
|
|
|
findModules = paths:
|
|
|
|
builtins.concatMap (path:
|
|
|
|
lib.pipe path [
|
2024-09-15 14:16:32 +02:00
|
|
|
(lib.fileset.fileFilter (
|
2024-12-24 19:29:19 +01:00
|
|
|
file: file.hasExt "nix"
|
2024-09-15 14:16:32 +02:00
|
|
|
))
|
|
|
|
lib.fileset.toList
|
|
|
|
])
|
2025-01-04 23:51:35 +01:00
|
|
|
paths;
|
2024-09-15 14:16:32 +02:00
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
mkIfElse =
|
|
|
|
condition: trueContent: falseContent:
|
2025-03-01 22:21:00 +01:00
|
|
|
lib.mkMerge [
|
|
|
|
(lib.mkIf condition trueContent)
|
|
|
|
(lib.mkIf (!condition) falseContent)
|
|
|
|
];
|
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
mkSecrets =
|
|
|
|
secrets:
|
|
|
|
let
|
|
|
|
mkSecret =
|
|
|
|
{
|
|
|
|
name,
|
|
|
|
secret,
|
|
|
|
}:
|
|
|
|
secret
|
|
|
|
// {
|
|
|
|
file = ./secrets/${name}.age;
|
|
|
|
};
|
|
|
|
in
|
|
|
|
builtins.mapAttrs (name: secret: mkSecret { inherit name secret; }) secrets;
|
2024-12-01 04:05:16 +01:00
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
genNixosConfigurations =
|
|
|
|
inputs:
|
|
|
|
let
|
|
|
|
modulesDir = ./modules;
|
|
|
|
profilesDir = ./profiles;
|
|
|
|
commonDir = ./common;
|
|
|
|
hostsDir = ./hosts;
|
2024-12-01 04:05:16 +01:00
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
commonNixosSystem =
|
|
|
|
name:
|
|
|
|
lib.nixosSystem {
|
|
|
|
specialArgs = {
|
|
|
|
inherit (inputs) self;
|
|
|
|
inherit inputs lib;
|
|
|
|
attrName = name;
|
|
|
|
};
|
2024-12-01 04:05:16 +01:00
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
modules =
|
|
|
|
(lib.findModules [
|
|
|
|
modulesDir
|
|
|
|
profilesDir
|
|
|
|
commonDir
|
|
|
|
(hostsDir + /${name})
|
|
|
|
]);
|
|
|
|
};
|
2024-12-01 04:05:16 +01:00
|
|
|
|
2025-05-11 22:49:04 +02:00
|
|
|
hosts = lib.pipe hostsDir [
|
2025-03-09 16:37:21 +01:00
|
|
|
builtins.readDir
|
2024-12-01 04:05:16 +01:00
|
|
|
(lib.filterAttrs (_: type: type == "directory"))
|
|
|
|
builtins.attrNames
|
|
|
|
];
|
2025-05-11 22:49:04 +02:00
|
|
|
in
|
|
|
|
lib.genAttrs hosts commonNixosSystem;
|
2024-09-15 14:16:32 +02:00
|
|
|
}
|