nichts/hosts/default.nix
Bloxx12 e641dfa114
treewide: format using nixfmt
Signed-off-by: Bloxx12 <charlie@charlieroot.dev>
Change-Id: I6a6a69641c36f9763e104087a559c148d0449f00
2025-07-20 02:14:32 +02:00

70 lines
1.8 KiB
Nix

{
sources,
nixpkgs,
self,
...
}:
let
inherit (builtins) filter map toString;
inherit (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;
inputs = sources;
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"))
(map toString (listFilesRecursive ../modules) |> filter (hasSuffix ".mod.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";
# };
}