68 lines
1.8 KiB
Nix
68 lines
1.8 KiB
Nix
inputs: let
|
|
inherit (inputs) self;
|
|
inherit (builtins) filter map toString;
|
|
inherit (inputs.nixpkgs) lib;
|
|
inherit (lib.attrsets) recursiveUpdate;
|
|
inherit (lib.filesystem) listFilesRecursive;
|
|
inherit (lib.lists) concatLists flatten singleton;
|
|
inherit (lib.strings) hasSuffix;
|
|
inherit (lib) nixosSystem;
|
|
# NOTE: This was inspired by raf, and I find this
|
|
# to be quite a sane way of managing all modules in my flake.
|
|
|
|
mkSystem = {
|
|
system,
|
|
hostname,
|
|
...
|
|
} @ args:
|
|
nixosSystem {
|
|
specialArgs =
|
|
recursiveUpdate
|
|
{
|
|
inherit lib;
|
|
inherit inputs;
|
|
inherit 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 = hostname;
|
|
nixpkgs.hostPlatform = system;
|
|
})
|
|
(
|
|
concatLists [
|
|
# configuration for the host, passed as an argument.
|
|
(singleton ./${hostname}/default.nix)
|
|
# common configuration, which all hosts share.
|
|
(singleton ./common.nix)
|
|
# Import all files called module.nix from my modules directory.
|
|
(
|
|
map toString (listFilesRecursive ../modules)
|
|
|> filter (hasSuffix "module.nix")
|
|
)
|
|
]
|
|
|> flatten
|
|
)
|
|
];
|
|
};
|
|
in {
|
|
temperance = mkSystem {
|
|
system = "x86_64-linux";
|
|
hostname = "temperance";
|
|
};
|
|
|
|
hermit = mkSystem {
|
|
system = "x86_64-linux";
|
|
hostname = "hermit";
|
|
};
|
|
tower = mkSystem {
|
|
system = "aarch64-linux";
|
|
hostname = "tower";
|
|
};
|
|
# world = mkSystem {
|
|
# system = "x86_64-linux";
|
|
# hostname = "world";
|
|
# };
|
|
}
|