nixos-config/hosts/default.nix

40 lines
1 KiB
Nix
Raw Normal View History

2021-04-13 00:42:45 +00:00
{ modules, unstable, stable2009 }:
2021-04-06 03:11:17 +00:00
let
2021-04-06 03:24:24 +00:00
2021-04-10 16:55:17 +00:00
hostMetadata =
let
2021-04-11 20:41:49 +00:00
fs = builtins.readDir ./.;
inherit (builtins) concatMap attrNames;
2021-04-10 16:55:17 +00:00
hostNames = concatMap (x: if fs.${x} == "directory" then [ x ] else [ ]) (attrNames fs);
in
2021-04-11 20:41:49 +00:00
builtins.listToAttrs (map
(hn: { name = hn; value = import (./. + "/${hn}"); })
hostNames);
2021-04-06 03:24:24 +00:00
2021-04-11 20:41:49 +00:00
hardwareModule = hardware: (
2021-04-10 16:55:17 +00:00
{
qemu = (x: { imports = [ "${x.modulesPath}/profiles/qemu-guest.nix" ]; });
2021-04-11 20:41:49 +00:00
physical = (x: { imports = [ "${x.modulesPath}/installer/scan/not-detected.nix" ]; });
2021-04-10 16:55:17 +00:00
}
).${hardware};
2021-04-06 03:11:17 +00:00
in
2021-04-11 20:41:49 +00:00
builtins.mapAttrs
(n: v:
let pkgs = { inherit unstable stable2009; }.${v.pkgs};
in
pkgs.lib.nixosSystem {
inherit (v) system;
2021-04-13 00:42:45 +00:00
modules = modules ++ [
2021-04-11 20:41:49 +00:00
(./. + "/${n}/configuration.nix")
(hardwareModule v.hardware)
({ ... }: {
networking.hostName = n;
sconfig.flakes.enable = true;
sconfig.flakes.rebuildPath = "github:buckley310/nixos-config";
})
];
}
)
hostMetadata