From 92ca826539092f33c8e19a19c7a9ea0def2aece0 Mon Sep 17 00:00:00 2001 From: seth Date: Mon, 17 Apr 2023 12:00:55 -0400 Subject: move most configurations to modules --- lib/host.nix | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 lib/host.nix (limited to 'lib/host.nix') diff --git a/lib/host.nix b/lib/host.nix new file mode 100644 index 0000000..b5e00b3 --- /dev/null +++ b/lib/host.nix @@ -0,0 +1,49 @@ +{ + inputs, + mapFilterDirs, +}: rec { + mkHost = { + name, + modules, + specialArgs ? {}, + system ? "x86_64-linux", + stateVersion ? "22.11", + pkgs, + }: + with pkgs.lib; + nixosSystem { + inherit system specialArgs; + modules = + [ + ../modules + ../hosts/${name} + + { + system.stateVersion = stateVersion; + networking.hostName = mkDefault name; + + nixpkgs = { + overlays = with inputs; [nur.overlay getchoo.overlays.default]; + config.allowUnfree = true; + }; + nix.registry.getchoo.flake = inputs.getchoo; + + nixos.enable = true; + } + ] + ++ modules; + }; + + mapHosts = inputs: let + hosts = import ../hosts inputs; + in + mapFilterDirs ../hosts (n: v: v == "directory" && n != "turret") (name: _: + mkHost { + inherit name; + inherit (hosts.${name}) modules system stateVersion pkgs; + specialArgs = + if builtins.hasAttr "specialArgs" hosts.${name} + then hosts.${name}.specialArgs + else {}; + }); +} -- cgit v1.2.3