From a02b2c2bc470e10e742299ee6d2159603ccb9a95 Mon Sep 17 00:00:00 2001 From: kalipso Date: Wed, 22 Jan 2025 04:22:43 +0100 Subject: [PATCH] [nix] generate hosts --- machines/configuration.nix | 211 ++++++++++++++++++++----------------- 1 file changed, 112 insertions(+), 99 deletions(-) diff --git a/machines/configuration.nix b/machines/configuration.nix index 0e7fd4b1..887023eb 100644 --- a/machines/configuration.nix +++ b/machines/configuration.nix @@ -95,104 +95,117 @@ let ] ++ defaultModules ++ modules; inputsMod = inputs // { malobeo = self; }; + + hosts = import ./modules/host_builer.nix {}; in -{ - louise = nixosSystem { - system = "x86_64-linux"; + builtins.mapAttrs (host: settings: nixosSystem { + system = if (settings.type == "rpi") then "aarch64-linux" else "x86_64-linux"; specialArgs.inputs = inputs; - modules = defaultModules ++ [ - ./louise/configuration.nix - ]; - }; - - bakunin = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - modules = defaultModules ++ [ - ./bakunin/configuration.nix - inputs.disko.nixosModules.disko - ]; - }; - - lucia = nixosSystem { - system = "aarch64-linux"; - specialArgs.inputs = inputs; - modules = defaultModules ++ [ - ./lucia/configuration.nix - ./lucia/hardware_configuration.nix - ]; - }; - - fanny = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputsMod; - modules = defaultModules ++ [ - self.nixosModules.malobeo.vpn - ./fanny/configuration.nix - ]; - }; - - durruti = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "durruti" "10.0.0.5" "52:DA:0D:F9:EF:F9" [ - ./durruti/configuration.nix - ]; - }; - - vpn = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "vpn" "10.0.0.10" "D0:E5:CA:F0:D7:E6" [ - self.nixosModules.malobeo.vpn - ./vpn/configuration.nix - ]; - }; - - infradocs = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "infradocs" "10.0.0.11" "D0:E5:CA:F0:D7:E7" [ - self.nixosModules.malobeo.vpn - ./infradocs/configuration.nix - ]; - }; - - uptimekuma = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "uptimekuma" "10.0.0.12" "D0:E5:CA:F0:D7:E8" [ - ./uptimekuma/configuration.nix - ]; - }; - - nextcloud = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "nextcloud" "10.0.0.13" "D0:E5:CA:F0:D7:E9" [ - ./nextcloud/configuration.nix - ]; - }; - - overwatch = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = makeMicroVM "overwatch" "10.0.0.14" "D0:E5:CA:F0:D7:E0" [ - ./overwatch/configuration.nix - ]; - }; - - testvm = nixosSystem { - system = "x86_64-linux"; - specialArgs.inputs = inputs; - specialArgs.self = self; - modules = defaultModules ++ [ ./testvm ]; - }; - -} + modules = (if (settings.type != "microvm") then + defaultModules ++ [ ./${host}/configuration.nix ] + else + makeMicroVM "${host}" "${settings.network.address}" "${settings.network.mac}" [ + ./${host}/configuration.nix + ]); + }) hosts.malobeo.hosts // + { + testvm = nixosSystem { + system = "x86_64-linux"; + specialArgs.inputs = inputs; + specialArgs.self = self; + modules = defaultModules ++ [ ./testvm ]; + }; + } +#{ +# louise = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# modules = defaultModules ++ [ +# ./louise/configuration.nix +# ]; +# }; +# +# bakunin = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# modules = defaultModules ++ [ +# ./bakunin/configuration.nix +# inputs.disko.nixosModules.disko +# ]; +# }; +# +# lucia = nixosSystem { +# system = "aarch64-linux"; +# specialArgs.inputs = inputs; +# modules = defaultModules ++ [ +# ./lucia/configuration.nix +# ./lucia/hardware_configuration.nix +# ]; +# }; +# +# fanny = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputsMod; +# modules = defaultModules ++ [ +# self.nixosModules.malobeo.vpn +# ./fanny/configuration.nix +# ]; +# }; +# +# durruti = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "durruti" "10.0.0.5" "52:DA:0D:F9:EF:F9" [ +# ./durruti/configuration.nix +# ]; +# }; +# +# vpn = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "vpn" "10.0.0.10" "D0:E5:CA:F0:D7:E6" [ +# self.nixosModules.malobeo.vpn +# ./vpn/configuration.nix +# ]; +# }; +# +# infradocs = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "infradocs" "10.0.0.11" "D0:E5:CA:F0:D7:E7" [ +# self.nixosModules.malobeo.vpn +# ./infradocs/configuration.nix +# ]; +# }; +# +# uptimekuma = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "uptimekuma" "10.0.0.12" "D0:E5:CA:F0:D7:E8" [ +# ./uptimekuma/configuration.nix +# ]; +# }; +# +# nextcloud = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "nextcloud" "10.0.0.13" "D0:E5:CA:F0:D7:E9" [ +# ./nextcloud/configuration.nix +# ]; +# }; +# +# overwatch = nixosSystem { +# system = "x86_64-linux"; +# specialArgs.inputs = inputs; +# specialArgs.self = self; +# modules = makeMicroVM "overwatch" "10.0.0.14" "D0:E5:CA:F0:D7:E0" [ +# ./overwatch/configuration.nix +# ]; +# }; +# +#}