nichts/hosts/default.nix

63 lines
1.5 KiB
Nix
Raw Normal View History

2024-11-01 14:51:13 +01:00
inputs: let
2024-10-29 18:44:22 +01:00
inherit (inputs) self;
2024-11-01 14:51:13 +01:00
inherit (inputs.nixpkgs) lib;
inherit (lib.lists) concatLists flatten singleton;
2024-11-08 12:47:32 +01:00
inherit (lib) nixosSystem recursiveUpdate;
2024-10-29 18:44:22 +01:00
inherit (builtins) filter map toString;
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.strings) hasSuffix;
2024-09-08 21:09:17 +02:00
# NOTE: This was inspired by raf, and I find this
# to be quite a sane way of managing all modules in my flake.
2024-10-29 18:44:22 +01:00
mkSystem = {
system,
hostname,
...
} @ args:
2024-11-01 14:51:13 +01:00
nixosSystem {
specialArgs =
recursiveUpdate
{
inherit lib;
inherit inputs;
inherit self;
2024-10-29 18:44:22 +01:00
}
2024-11-01 14:51:13 +01:00
(args.specialArgs or {});
modules = concatLists [
# This is used to pre-emptively set the hostPlatform for nixpkgs.
# Also, we set the system hostname here.
2024-11-06 00:11:11 +01:00
[
self.nixosModules.user
]
2024-11-01 14:51:13 +01:00
(singleton {
networking.hostName = hostname;
nixpkgs.hostPlatform = system;
2024-11-01 14:51:13 +01:00
})
(flatten (
concatLists [
(singleton ./${hostname}/default.nix)
(
filter (hasSuffix "module.nix") (
map toString (listFilesRecursive ../modules)
)
)
]
))
];
};
2024-11-01 14:51:13 +01:00
in {
temperance = mkSystem {
system = "x86_64-linux";
hostname = "temperance";
};
2024-07-21 20:14:19 +02:00
2024-11-01 14:51:13 +01:00
hermit = mkSystem {
system = "x86_64-linux";
hostname = "hermit";
2024-04-10 17:56:10 +02:00
};
2025-03-02 19:42:33 +01:00
tower = mkSystem {
system = "aarch64-linux";
2025-03-02 19:42:33 +01:00
hostname = "tower";
};
2024-04-10 17:56:53 +02:00
}