hosts/default.nix: change mkSystem
This commit is contained in:
parent
b5c51ce76f
commit
1ec9561919
1 changed files with 49 additions and 19 deletions
|
@ -3,42 +3,72 @@
|
||||||
inputs,
|
inputs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (inputs.self) lib;
|
inherit (inputs) self;
|
||||||
inherit (lib.extendedLib.builders) mkSystem;
|
inherit (self) lib;
|
||||||
inherit (lib.extendedLib.modules) mkModuleTree';
|
# inherit (lib.extendedLib.builders) mkSystem;
|
||||||
|
# inherit (lib.extendedLib.modules) mkModuleTree';
|
||||||
inherit (lib.lists) concatLists flatten singleton;
|
inherit (lib.lists) concatLists flatten singleton;
|
||||||
|
inherit (lib) mkDefault nixosSystem recursiveUpdate;
|
||||||
|
inherit (builtins) filter map toString;
|
||||||
|
inherit (lib.filesystem) listFilesRecursive;
|
||||||
|
inherit (lib.strings) hasSuffix;
|
||||||
# NOTE: This was inspired by raf, and I find this
|
# NOTE: This was inspired by raf, and I find this
|
||||||
# to be quite a sane way of managing all modules in my flake.
|
# to be quite a sane way of managing all modules in my flake.
|
||||||
|
|
||||||
mkModulesFor = hostname:
|
mkSystem = {
|
||||||
flatten (
|
withSystem,
|
||||||
|
system,
|
||||||
|
hostname,
|
||||||
|
...
|
||||||
|
} @ args:
|
||||||
|
withSystem system (
|
||||||
|
{
|
||||||
|
inputs',
|
||||||
|
self',
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
nixosSystem {
|
||||||
|
inherit system;
|
||||||
|
specialArgs =
|
||||||
|
recursiveUpdate
|
||||||
|
{
|
||||||
|
inherit lib;
|
||||||
|
inherit inputs inputs';
|
||||||
|
inherit self self';
|
||||||
|
}
|
||||||
|
(args.specialArgs or {});
|
||||||
|
modules = concatLists [
|
||||||
|
# This is used to pre-emptively set the hostPlatform for nixpkgs.
|
||||||
|
# Also, we set the system hostname here.
|
||||||
|
(singleton {
|
||||||
|
networking.hostName = args.hostname;
|
||||||
|
nixpkgs.hostPlatform = mkDefault args.system;
|
||||||
|
})
|
||||||
|
(flatten (
|
||||||
concatLists [
|
concatLists [
|
||||||
# Derive host specific module path from the first argument of the
|
|
||||||
# function. Should be a string, obviously.
|
|
||||||
(singleton ./${hostname}/default.nix)
|
(singleton ./${hostname}/default.nix)
|
||||||
|
(
|
||||||
# Recursively import all module trees (i.e. directories with a `module.nix`)
|
filter (hasSuffix "module.nix") (
|
||||||
# for given moduleTree directories
|
map toString (listFilesRecursive ../modules)
|
||||||
(mkModuleTree' {path = ../modules;})
|
)
|
||||||
|
)
|
||||||
]
|
]
|
||||||
|
))
|
||||||
|
];
|
||||||
|
}
|
||||||
);
|
);
|
||||||
in {
|
in {
|
||||||
flake.nixosConfigurations = {
|
flake.nixosConfigurations = {
|
||||||
temperance = mkSystem {
|
temperance = mkSystem {
|
||||||
inherit withSystem;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
|
||||||
hostname = "temperance";
|
hostname = "temperance";
|
||||||
modules = mkModulesFor "temperance";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
hermit = mkSystem {
|
hermit = mkSystem {
|
||||||
inherit withSystem;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
|
|
||||||
hostname = "hermit";
|
hostname = "hermit";
|
||||||
modules = mkModulesFor "hermit";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue