nichts/hosts/default.nix

73 lines
1.9 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
}
2025-07-08 13:57:04 +02:00
args.specialArgs or {};
2024-11-01 14:51:13 +01:00
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
})
2025-06-04 08:27:12 +02:00
(
2024-11-01 14:51:13 +01:00
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
(
2025-06-04 08:27:12 +02:00
map toString (listFilesRecursive ../modules)
|> filter (hasSuffix "module.nix")
2024-11-01 14:51:13 +01:00
)
2025-07-13 22:51:22 +02:00
(
map toString (listFilesRecursive ../modules)
|> filter (hasSuffix ".mod.nix")
)
2024-11-01 14:51:13 +01:00
]
2025-06-04 08:27:12 +02:00
|> flatten
)
2024-11-01 14:51:13 +01:00
];
};
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";
};
2025-06-04 08:27:12 +02:00
# world = mkSystem {
# system = "x86_64-linux";
# hostname = "world";
# };
2024-04-10 17:56:53 +02:00
}