diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-09-20 02:18:09 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-09-20 02:23:35 +0200 |
commit | daaf66420582db82f8cad09510324656d429d229 (patch) | |
tree | d335d4265669c7ad3dee658389bacda787830b42 /hosts/default.nix | |
parent | Misc: Remove code duplication by merging sets (diff) | |
download | nixos-config-daaf66420582db82f8cad09510324656d429d229.tar.gz nixos-config-daaf66420582db82f8cad09510324656d429d229.tar.bz2 nixos-config-daaf66420582db82f8cad09510324656d429d229.zip |
Fully separate hosts from hardwares
Now hosts/ and hardware/ live under different directories and their joined system configurations are permutated and exposed throught the host-hardware outputs
Diffstat (limited to 'hosts/default.nix')
-rw-r--r-- | hosts/default.nix | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/hosts/default.nix b/hosts/default.nix index a43f2bd..2a1f526 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -2,11 +2,16 @@ let secrets = import ../secrets; - #TODO: Better implementation of hardare (not having to declare here but just in command) hosts = [ - { host = "phobos"; hardware = "laptop"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } - { host = "luna"; hardware = "chromebook"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } - { host = "vm"; hardware = "virtualbox"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } + { host = "phobos"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } + { host = "luna"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } + { host = "vm"; system = "x86_64-linux"; timezone = secrets.main_timezone; location = secrets.main_location; } + ]; + + hardwares = [ + { hardware = "laptop"; } + { hardware = "chromebook"; } + { hardware = "virtualbox"; } ]; mkHost = { host, hardware, system, timezone, location }: extraModules: isNixOS: isIso: isHardware: @@ -26,7 +31,7 @@ let extraArgs = { inherit pkgs inputs isIso isHardware user secrets timezone location; hostname = host; }; #TODO: FIXME extraSpecialModules = if isIso then extraModules ++ [ "${nixpkgs}/nixos/modules/installer/cd-dvd/installation-cd-minimal.nix" ] else extraModules; - megaSpecialModules = if isHardware then extraSpecialModules ++ [ ./${ host}/hardware/${hardware} ] else extraSpecialModules; + megaSpecialModules = if isHardware then extraSpecialModules ++ [ ../hardware/${hardware} ] else extraSpecialModules; in if isNixOS then @@ -61,10 +66,12 @@ let ./${ host }/home.nix ]; }; + + permutatedHosts = lib.concatMap (hardware: map (host: host // hardware) hosts) hardwares; in /* We have a list of sets. Map each element of the list applying the mkHost function to its elements and returning a set in the listToAttrs format builtins.listToAttrs on the result */ -builtins.listToAttrs (map ({ host, hardware, system, timezone, location }: { name = host; value = mkHost { inherit host hardware system timezone location; } extraModules isNixOS isIso isHardware; }) hosts) +builtins.listToAttrs (map ({ host, hardware, system, timezone, location }: { name = host + "-" + hardware; value = mkHost { inherit host hardware system timezone location; } extraModules isNixOS isIso isHardware; }) permutatedHosts) |