migrate system scanning logic to lib/

Signed-off-by: ahuston-0 <aliceghuston@gmail.com>
This commit is contained in:
2024-05-19 10:26:46 -04:00
committed by Alice Huston
parent 6b5dda1f39
commit 46aee20d9e
3 changed files with 49 additions and 49 deletions

View File

@ -28,32 +28,33 @@ rec {
};
}) users);
genUsers =
{ users, src, ... }:
(map (
user:
{
config,
lib,
pkgs,
...
}@args:
{
users.users.${user} = import (src + "/users/${user}") (args // { name = user; });
}
) users);
importUser =
user: src:
{
config,
lib,
pkgs,
...
}@args:
{
users.users.${user} = import (src + "/users/${user}") (args // { name = user; });
};
genUsers = { users, src, ... }: (map (user: importUser user src) users);
genNonX86 =
{ ... }:
{
config.nixpkgs = {
config.allowUnsupportedSystem = true;
buildPlatform = "x86_64-linux";
};
};
genWrapper =
var: func: args:
lib.optionals var (func args);
nonX86 = {
config.nixpkgs = {
config.allowUnsupportedSystem = true;
buildPlatform = "x86_64-linux";
};
};
constructSystem =
{
hostname,
@ -80,9 +81,25 @@ rec {
(src + "/systems/${hostname}/configuration.nix")
]
++ modules
++ (lib.rad-dev.fileList src "modules")
++ (lib.rad-dev.fileList (src + "/modules"))
++ genWrapper sops genSops args
++ genWrapper home genHome args
++ genWrapper true genUsers args;
++ genWrapper true genUsers args
++ genWrapper (system != "x86_64-linux") genNonX86 args;
};
genSystems =
inputs: src: path:
builtins.listToAttrs (
map (name: {
inherit name;
value = constructSystem (
{
inherit inputs src;
hostname = name;
}
// import (path + "/${name}") { inherit inputs; }
);
}) (lib.rad-dev.lsdir path)
);
}