From 985b4d4c17af0801c1559b6353ed6236ecbbd113 Mon Sep 17 00:00:00 2001 From: clerie Date: Thu, 23 May 2024 13:51:06 +0200 Subject: [PATCH] flake/nixosConfigurations.nix: Generate hostname from host attribute name --- flake.nix | 47 ++++++++++------------ flake/nixosConfigurations.nix | 5 ++- hosts/aluminium/configuration.nix | 2 - hosts/astatine/configuration.nix | 2 - hosts/backup-4/configuration.nix | 2 - hosts/carbon/configuration.nix | 2 - hosts/clerie-backup/configuration.nix | 2 - hosts/dn42-il-gw1/configuration.nix | 2 - hosts/dn42-il-gw5/configuration.nix | 2 - hosts/dn42-il-gw6/configuration.nix | 2 - hosts/dn42-ildix-clerie/configuration.nix | 2 - hosts/dn42-ildix-service/configuration.nix | 3 -- hosts/gatekeeper/configuration.nix | 2 - hosts/hydra-1/configuration.nix | 2 - hosts/hydra-2/configuration.nix | 2 - hosts/krypton/configuration.nix | 2 - hosts/mail-2/configuration.nix | 2 - hosts/minecraft-2/configuration.nix | 2 - hosts/monitoring-3/configuration.nix | 2 - hosts/nonat/configuration.nix | 2 - hosts/osmium/configuration.nix | 2 - hosts/palladium/configuration.nix | 2 - hosts/porter/configuration.nix | 2 - hosts/storage-2/configuration.nix | 2 - hosts/web-2/configuration.nix | 2 - hosts/zinc/configuration.nix | 2 - 26 files changed, 25 insertions(+), 76 deletions(-) diff --git a/flake.nix b/flake.nix index c3ef0ba..a1e93ea 100644 --- a/flake.nix +++ b/flake.nix @@ -43,55 +43,50 @@ in { clerie.hosts = { aluminium = { - name = "aluminium"; group = "event"; }; astatine = { - name = "astatine"; group = "event"; modules = [ ./users/criese-nethinks ./users/isa ]; }; - backup-4 = { name = "backup-4"; }; + backup-4 = {}; beryllium = { - name = "beryllium"; group = "event"; }; - carbon = { name = "carbon"; }; - clerie-backup = { name = "clerie-backup"; }; - dn42-il-gw1 = { name = "dn42-il-gw1"; }; - dn42-il-gw5 = { name = "dn42-il-gw5"; }; - dn42-il-gw6 = { name = "dn42-il-gw6"; }; - dn42-ildix-clerie = { name = "dn42-ildix-clerie"; }; - dn42-ildix-service = { name = "dn42-ildix-service"; }; - gatekeeper = { name = "gatekeeper"; }; - hydra-1 = { name = "hydra-1"; }; - hydra-2 = { name = "hydra-2"; }; + carbon = {}; + clerie-backup = {}; + dn42-il-gw1 = {}; + dn42-il-gw5 = {}; + dn42-il-gw6 = {}; + dn42-ildix-clerie = {}; + dn42-ildix-service = {}; + gatekeeper = {}; + hydra-1 = {}; + hydra-2 = {}; krypton = { - name = "krypton"; modules = [ nixos-hardware.nixosModules.lenovo-thinkpad-x270 ]; }; - mail-2 = { name = "mail-2"; }; - minecraft-2 = { name = "minecraft-2"; }; - monitoring-3 = { name = "monitoring-3"; }; - nonat = { name = "nonat"; }; - osmium = { name = "osmium"; }; - palladium = { name = "palladium"; }; - porter = { name = "porter"; }; - storage-2 = { name = "storage-2"; }; - web-2 = { name = "web-2"; }; + mail-2 = {}; + minecraft-2 = {}; + monitoring-3 = {}; + nonat = {}; + osmium = {}; + palladium = {}; + porter = {}; + storage-2 = {}; + web-2 = {}; zinc = { - name = "zinc"; modules = [ nixos-hardware.nixosModules.common-cpu-intel ]; }; # nixfiles-auto-install: add new host above - _iso = { name = "_iso"; }; + _iso = {}; }; nixosConfigurations = import ./flake/nixosConfigurations.nix inputs; diff --git a/flake/nixosConfigurations.nix b/flake/nixosConfigurations.nix index 276d3c5..dd969aa 100644 --- a/flake/nixosConfigurations.nix +++ b/flake/nixosConfigurations.nix @@ -18,6 +18,9 @@ let self.nixosModules.clerie ({ config, lib, ... }: { + # Set hostname + networking.hostName = lib.mkDefault name; + # Apply overlays nixpkgs.overlays = [ self.overlays.nixfilesInputs @@ -59,7 +62,7 @@ let ]; }; - mapToNixosConfigurations = hosts: builtins.mapAttrs (name: host: generateNixosSystem host) hosts; + mapToNixosConfigurations = hosts: builtins.mapAttrs (name: host: generateNixosSystem ({ inherit name; } // host)) hosts; in mapToNixosConfigurations self.clerie.hosts diff --git a/hosts/aluminium/configuration.nix b/hosts/aluminium/configuration.nix index ced9cdd..6651cfd 100644 --- a/hosts/aluminium/configuration.nix +++ b/hosts/aluminium/configuration.nix @@ -18,8 +18,6 @@ terminal_output serial "; - networking.hostName = "aluminium"; - services.wg-clerie = { enable = true; ipv6s = [ "2a01:4f8:c0c:15f1::8106/128" ]; diff --git a/hosts/astatine/configuration.nix b/hosts/astatine/configuration.nix index 325b0b3..bb19fa7 100644 --- a/hosts/astatine/configuration.nix +++ b/hosts/astatine/configuration.nix @@ -25,8 +25,6 @@ terminal_output serial "; - networking.hostName = "astatine"; - #networking.firewall.enable = false; services.wg-clerie = { diff --git a/hosts/backup-4/configuration.nix b/hosts/backup-4/configuration.nix index 0e8481a..8f6dc42 100644 --- a/hosts/backup-4/configuration.nix +++ b/hosts/backup-4/configuration.nix @@ -13,8 +13,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "backup-4"; - networking.useDHCP = false; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffcb::c"; prefixLength = 64; } ]; networking.defaultGateway6 = { address = "2001:638:904:ffcb::1"; interface = "ens18"; }; diff --git a/hosts/carbon/configuration.nix b/hosts/carbon/configuration.nix index 4bb00d7..06b8004 100644 --- a/hosts/carbon/configuration.nix +++ b/hosts/carbon/configuration.nix @@ -17,8 +17,6 @@ terminal_output serial "; - networking.hostName = "carbon"; - networking.useDHCP = false; # Local Router IPs networking.interfaces.lo.ipv6.addresses = [ diff --git a/hosts/clerie-backup/configuration.nix b/hosts/clerie-backup/configuration.nix index a28718f..24942cf 100644 --- a/hosts/clerie-backup/configuration.nix +++ b/hosts/clerie-backup/configuration.nix @@ -14,8 +14,6 @@ boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; - networking.hostName = "clerie-backup"; - networking.useDHCP = false; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffc1::6"; prefixLength = 64; } ]; networking.defaultGateway6 = { address = "2001:638:904:ffc1::1"; interface = "ens18"; }; diff --git a/hosts/dn42-il-gw1/configuration.nix b/hosts/dn42-il-gw1/configuration.nix index 19bbea7..9d2c07c 100644 --- a/hosts/dn42-il-gw1/configuration.nix +++ b/hosts/dn42-il-gw1/configuration.nix @@ -11,8 +11,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "dn42-il-gw1"; - networking.useDHCP = false; networking.interfaces.lo.ipv6.addresses = [ { address = "fd56:4902:eca0:1::1"; prefixLength = 64; } ]; # VM Nat Netz mercury diff --git a/hosts/dn42-il-gw5/configuration.nix b/hosts/dn42-il-gw5/configuration.nix index d70741e..133314d 100644 --- a/hosts/dn42-il-gw5/configuration.nix +++ b/hosts/dn42-il-gw5/configuration.nix @@ -11,8 +11,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "dn42-il-gw5"; - networking.useDHCP = false; # VM Nat Netz mercury networking.interfaces.ens18.ipv4.addresses = [ { address = "192.168.10.25"; prefixLength = 24; } ]; diff --git a/hosts/dn42-il-gw6/configuration.nix b/hosts/dn42-il-gw6/configuration.nix index 60eb067..967eb0d 100644 --- a/hosts/dn42-il-gw6/configuration.nix +++ b/hosts/dn42-il-gw6/configuration.nix @@ -11,8 +11,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "dn42-il-gw6"; - networking.useDHCP = false; networking.interfaces.lo.ipv6.addresses = [ { address = "fd56:4902:eca0:6::1"; prefixLength = 64; } ]; # IPv6 Uplink diff --git a/hosts/dn42-ildix-clerie/configuration.nix b/hosts/dn42-ildix-clerie/configuration.nix index 9f0efd9..14e6387 100644 --- a/hosts/dn42-ildix-clerie/configuration.nix +++ b/hosts/dn42-ildix-clerie/configuration.nix @@ -10,8 +10,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "dn42-ildix-clerie"; - networking.useDHCP = false; # VM Nat Netz mercury networking.interfaces.ens18.ipv4.addresses = [ { address = "192.168.10.27"; prefixLength = 24; } ]; diff --git a/hosts/dn42-ildix-service/configuration.nix b/hosts/dn42-ildix-service/configuration.nix index dae07f6..b9093de 100644 --- a/hosts/dn42-ildix-service/configuration.nix +++ b/hosts/dn42-ildix-service/configuration.nix @@ -17,9 +17,6 @@ # Define on which hard drive you want to install Grub. boot.loader.grub.device = "/dev/vda"; # or "nodev" for efi only - - networking.hostName = "dn42-ildix-service"; - networking.useDHCP = false; networking.interfaces.lo.ipv6.addresses = [ { address = "fd81:edb3:71d8::1"; prefixLength = 128; } diff --git a/hosts/gatekeeper/configuration.nix b/hosts/gatekeeper/configuration.nix index 03aae1e..57e3c0a 100644 --- a/hosts/gatekeeper/configuration.nix +++ b/hosts/gatekeeper/configuration.nix @@ -10,8 +10,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "gatekeeper"; - networking.useDHCP = false; # Network networking.interfaces.ens3.ipv4.addresses = [ { address = "78.47.183.82"; prefixLength = 32; } ]; diff --git a/hosts/hydra-1/configuration.nix b/hosts/hydra-1/configuration.nix index bc31992..89c7d50 100644 --- a/hosts/hydra-1/configuration.nix +++ b/hosts/hydra-1/configuration.nix @@ -21,8 +21,6 @@ "aarch64-linux" ]; - networking.hostName = "hydra-1"; - networking.useDHCP = false; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffcb::a"; prefixLength = 64; } ]; networking.interfaces.ens19.ipv4.addresses = [ { address = "192.168.10.36"; prefixLength = 24; } ]; diff --git a/hosts/hydra-2/configuration.nix b/hosts/hydra-2/configuration.nix index 418600b..88abe46 100644 --- a/hosts/hydra-2/configuration.nix +++ b/hosts/hydra-2/configuration.nix @@ -17,8 +17,6 @@ "aarch64-linux" ]; - networking.hostName = "hydra-2"; - networking.useDHCP = false; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffc1::100"; prefixLength = 64; } ]; networking.interfaces.ens18.ipv4.addresses = [ { address = "141.24.50.112"; prefixLength = 24; } ]; diff --git a/hosts/krypton/configuration.nix b/hosts/krypton/configuration.nix index 9f703ad..87f1198 100644 --- a/hosts/krypton/configuration.nix +++ b/hosts/krypton/configuration.nix @@ -28,8 +28,6 @@ # https://wiki.clerie.de/notiz/pm-hibernation-image-allocation-is-97054-pages-short boot.kernel.sysctl."vm.swappiness" = 1; - networking.hostName = "krypton"; - boot.binfmt.emulatedSystems = [ "aarch64-linux" ]; diff --git a/hosts/mail-2/configuration.nix b/hosts/mail-2/configuration.nix index a7ce61d..27e74b0 100644 --- a/hosts/mail-2/configuration.nix +++ b/hosts/mail-2/configuration.nix @@ -12,8 +12,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "mail-2"; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:1c1c:9577::1"; prefixLength = 64; } ]; networking.interfaces.ens3.ipv4.addresses = [ { address = "5.75.187.112"; prefixLength = 32; } ]; diff --git a/hosts/minecraft-2/configuration.nix b/hosts/minecraft-2/configuration.nix index 2500129..ae1cd0b 100644 --- a/hosts/minecraft-2/configuration.nix +++ b/hosts/minecraft-2/configuration.nix @@ -17,8 +17,6 @@ in { boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "minecraft-2"; - networking.useDHCP = false; networking.interfaces.ens19.ipv4.addresses = [ { address = "192.168.10.31"; prefixLength = 24; } ]; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffcb::9"; prefixLength = 64; } ]; diff --git a/hosts/monitoring-3/configuration.nix b/hosts/monitoring-3/configuration.nix index 5149f70..f811b0d 100644 --- a/hosts/monitoring-3/configuration.nix +++ b/hosts/monitoring-3/configuration.nix @@ -16,8 +16,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "monitoring-3"; - networking.useDHCP = false; networking.interfaces.ens18.ipv4.addresses = [ { address = "192.168.10.32"; prefixLength = 24; } ]; networking.interfaces.ens19.ipv6.addresses = [ { address = "2001:638:904:ffca::7"; prefixLength = 64; } ]; diff --git a/hosts/nonat/configuration.nix b/hosts/nonat/configuration.nix index b76b737..61f6c64 100644 --- a/hosts/nonat/configuration.nix +++ b/hosts/nonat/configuration.nix @@ -11,8 +11,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "nonat"; - networking.useDHCP = false; # Network networking.interfaces.ens18.ipv4.addresses = [ diff --git a/hosts/osmium/configuration.nix b/hosts/osmium/configuration.nix index 1e1a05e..8166fd2 100644 --- a/hosts/osmium/configuration.nix +++ b/hosts/osmium/configuration.nix @@ -19,8 +19,6 @@ "aarch64-linux" ]; - networking.hostName = "osmium"; - networking.useDHCP = false; networking.interfaces.ens18.ipv4.addresses = [ { address = "192.168.10.29"; prefixLength = 24; } ]; networking.interfaces.ens19.ipv6.addresses = [ { address = "2001:638:904:ffc7::6"; prefixLength = 64; } ]; diff --git a/hosts/palladium/configuration.nix b/hosts/palladium/configuration.nix index 41d9e16..2a47953 100644 --- a/hosts/palladium/configuration.nix +++ b/hosts/palladium/configuration.nix @@ -11,8 +11,6 @@ boot.loader.systemd-boot.enable = true; boot.loader.efi.canTouchEfiVariables = true; - networking.hostName = "palladium"; - networking.useDHCP = false; networking.interfaces.enp3s0.ipv6.addresses = [ { address = "fd00:152:152:4::11"; prefixLength = 64; } diff --git a/hosts/porter/configuration.nix b/hosts/porter/configuration.nix index b3603d2..d68e1b4 100644 --- a/hosts/porter/configuration.nix +++ b/hosts/porter/configuration.nix @@ -10,8 +10,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "porter"; - networking.useDHCP = false; # Network networking.interfaces.ens3.ipv4.addresses = [ { address = "5.45.100.191"; prefixLength = 22; } ]; diff --git a/hosts/storage-2/configuration.nix b/hosts/storage-2/configuration.nix index f067acb..457e63f 100644 --- a/hosts/storage-2/configuration.nix +++ b/hosts/storage-2/configuration.nix @@ -14,8 +14,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/vda"; - networking.hostName = "storage-2"; - networking.useDHCP = false; networking.interfaces.ens19.ipv4.addresses = [ { address = "192.168.10.35"; prefixLength = 24; } ]; networking.interfaces.ens18.ipv6.addresses = [ { address = "2001:638:904:ffc0::4"; prefixLength = 64; } ]; diff --git a/hosts/web-2/configuration.nix b/hosts/web-2/configuration.nix index 65a3e45..61e6b39 100644 --- a/hosts/web-2/configuration.nix +++ b/hosts/web-2/configuration.nix @@ -31,8 +31,6 @@ boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - networking.hostName = "web-2"; - networking.useDHCP = false; # Network networking.interfaces.ens3.ipv4.addresses = [ { address = "88.99.187.135"; prefixLength = 32; } ]; diff --git a/hosts/zinc/configuration.nix b/hosts/zinc/configuration.nix index d4c222b..c6ada40 100644 --- a/hosts/zinc/configuration.nix +++ b/hosts/zinc/configuration.nix @@ -23,8 +23,6 @@ }; }; - networking.hostName = "zinc"; - services.wg-clerie = { enable = true; ipv6s = [ "2a01:4f8:c0c:15f1::8109/128" ];