nichts/hosts/default.nix

65 lines
1.7 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;
inherit (builtins) filter map toString;
inherit (inputs.nixpkgs) lib;
inherit (lib.attrsets) recursiveUpdate;
2024-10-29 18:44:22 +01:00
inherit (lib.filesystem) listFilesRecursive;
inherit (lib.lists) concatLists flatten singleton;
2024-10-29 18:44:22 +01:00
inherit (lib.strings) hasSuffix;
inherit (lib) nixosSystem;
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.
(singleton {
networking.hostName = hostname;
nixpkgs.hostPlatform = system;
2024-11-01 14:51:13 +01:00
})
(flatten (
concatLists [
2025-04-09 15:31:18 +02:00
# configuration for the host, passed as an argument.
2024-11-01 14:51:13 +01:00
(singleton ./${hostname}/default.nix)
2025-04-09 15:31:18 +02:00
# common configuration, which all hosts share.
(singleton ./common.nix)
2025-04-09 15:31:18 +02:00
# Import all files called module.nix from my modules directory.
2024-11-01 14:51:13 +01:00
(
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
}