diff --git a/configuration/hetzner-cloud/default.nix b/configuration/hetzner-cloud/default.nix deleted file mode 100644 index c962933..0000000 --- a/configuration/hetzner-cloud/default.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ ... }: - -{ - networking.useDHCP = false; - networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; - networking.defaultGateway = { address = "172.31.1.1"; interface = "ens3"; }; - networking.nameservers = [ "2a01:4ff:ff00::add:2" "2a01:4ff:ff00::add:1" "185.12.64.2" "185.12.64.1" ]; -} diff --git a/flake.lock b/flake.lock index c2e4f2b..4d2f255 100644 --- a/flake.lock +++ b/flake.lock @@ -542,11 +542,11 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1741513245, - "narHash": "sha256-7rTAMNTY1xoBwz0h7ZMtEcd8LELk9R5TzBPoHuhNSCk=", + "lastModified": 1741851582, + "narHash": "sha256-cPfs8qMccim2RBgtKGF+x9IBCduRvd/N5F4nYpU0TVE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e3e32b642a31e6714ec1b712de8c91a3352ce7e1", + "rev": "6607cf789e541e7873d40d3a8f7815ea92204f32", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index a5ce04f..0a2791a 100644 --- a/flake.nix +++ b/flake.nix @@ -120,6 +120,7 @@ nixosModules = { nixfilesInputs = import ./flake/modules.nix inputs; clerie = import ./modules; + profiles = import ./profiles; default = self.nixosModules.clerie; }; diff --git a/flake/nixosConfigurations.nix b/flake/nixosConfigurations.nix index dd969aa..be4df26 100644 --- a/flake/nixosConfigurations.nix +++ b/flake/nixosConfigurations.nix @@ -16,6 +16,7 @@ let modules = modules ++ [ self.nixosModules.nixfilesInputs self.nixosModules.clerie + self.nixosModules.profiles ({ config, lib, ... }: { # Set hostname diff --git a/hosts/gatekeeper/configuration.nix b/hosts/gatekeeper/configuration.nix index f09e259..4c7eee9 100644 --- a/hosts/gatekeeper/configuration.nix +++ b/hosts/gatekeeper/configuration.nix @@ -7,16 +7,20 @@ ../../configuration/router ]; + profiles.clerie.hetzner-cloud.enable = true; + boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - # Network - networking.interfaces.ens3.ipv4.addresses = [ { address = "78.47.183.82"; prefixLength = 32; } ]; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:c0c:15f1::1"; prefixLength = 64; } ]; - networking.defaultGateway = { address = "172.31.1.1"; interface = "ens3"; }; - networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; - networking.nameservers = [ "213.133.98.98" "213.133.99.99" "213.133.100.100" ]; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:c0c:15f1::1/64" + "78.47.183.82/32" + ]; + }; networking.nat = { enable = true; diff --git a/hosts/mail-2/configuration.nix b/hosts/mail-2/configuration.nix index 27e74b0..0086f74 100644 --- a/hosts/mail-2/configuration.nix +++ b/hosts/mail-2/configuration.nix @@ -4,16 +4,24 @@ imports = [ ./hardware-configuration.nix - ../../configuration/hetzner-cloud ./mailcow.nix ]; + profiles.clerie.hetzner-cloud.enable = true; + boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; - 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; } ]; + networking.useDHCP = false; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:1c1c:9577::1/64" + "5.75.187.112/32" + ]; + }; clerie.backup = { enable = true; diff --git a/hosts/porter/configuration.nix b/hosts/porter/configuration.nix index 25ccad4..7974fb1 100644 --- a/hosts/porter/configuration.nix +++ b/hosts/porter/configuration.nix @@ -7,16 +7,25 @@ ../../configuration/router ]; + profiles.clerie.netcup.enable = true; + boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - # Network - networking.interfaces.ens3.ipv4.addresses = [ { address = "5.45.100.191"; prefixLength = 22; } ]; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a03:4000:6:48d::1"; prefixLength = 64; } ]; - networking.defaultGateway = { address = "5.45.100.1"; interface = "ens3"; }; - networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; - networking.nameservers = [ "46.38.255.230" "46.38.252.230" ]; + systemd.network.enable = true; + systemd.network.networks."10-wan" = { + matchConfig.Name = "ens3"; + address = [ + "2a03:4000:6:48d::1/64" + "5.45.100.191/22" + ]; + routes = [ + { Gateway = "fe80::1"; } + { Gateway = "5.45.100.1"; } + ]; + linkConfig.RequiredForOnline = "routable"; + }; clerie.nginx-port-forward = { enable = true; diff --git a/hosts/web-2/configuration.nix b/hosts/web-2/configuration.nix index 0565c80..93ea4f5 100644 --- a/hosts/web-2/configuration.nix +++ b/hosts/web-2/configuration.nix @@ -28,16 +28,20 @@ ./wetter.nix ]; + profiles.clerie.hetzner-cloud.enable = true; + boot.loader.grub.enable = true; boot.loader.grub.device = "/dev/sda"; networking.useDHCP = false; - # Network - networking.interfaces.ens3.ipv4.addresses = [ { address = "88.99.187.135"; prefixLength = 32; } ]; - networking.interfaces.ens3.ipv6.addresses = [ { address = "2a01:4f8:c0c:c580::1"; prefixLength = 64; } ]; - networking.defaultGateway = { address = "172.31.1.1"; interface = "ens3"; }; - networking.defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; - networking.nameservers = [ "213.133.98.98" "213.133.99.99" "213.133.100.100" ]; + systemd.network.enable = true; + + systemd.network.networks."10-wan" = { + address = [ + "2a01:4f8:c0c:c580::1/64" + "88.99.187.135/32" + ]; + }; services.nginx = { enable = true; diff --git a/profiles/default.nix b/profiles/default.nix new file mode 100644 index 0000000..9bba5e6 --- /dev/null +++ b/profiles/default.nix @@ -0,0 +1,10 @@ +{ ... }: + +{ + + imports = [ + ./hetzner-cloud + ./netcup + ]; + +} diff --git a/profiles/hetzner-cloud/default.nix b/profiles/hetzner-cloud/default.nix new file mode 100644 index 0000000..0de705b --- /dev/null +++ b/profiles/hetzner-cloud/default.nix @@ -0,0 +1,36 @@ +{ config, lib, ... }: + +with lib; + +{ + + options.profiles.clerie.hetzner-cloud = { + enable = mkEnableOption "Profile for Hetzner Cloud VMs"; + }; + + config = mkIf config.profiles.clerie.hetzner-cloud.enable { + + services.qemuGuest.enable = true; + + systemd.network.networks."10-wan" = { + matchConfig.Name = "ens3"; + routes = [ + { Gateway = "fe80::1"; } + { Gateway = "172.31.1.1"; GatewayOnLink = true; } + ]; + linkConfig.RequiredForOnline = "routable"; + }; + + networking.nameservers = [ + # There are two different batches of DNS servers + # This one + "2a01:4ff:ff00::add:2" "2a01:4ff:ff00::add:1" + "185.12.64.2" "185.12.64.1" + # And that one + "213.133.98.98" "213.133.99.99" "213.133.100.100" + # Couldn't find out which to use + ]; + + }; + +} diff --git a/profiles/netcup/default.nix b/profiles/netcup/default.nix new file mode 100644 index 0000000..abc7e39 --- /dev/null +++ b/profiles/netcup/default.nix @@ -0,0 +1,20 @@ +{ config, lib, ... }: + +with lib; + +{ + + options.profiles.clerie.netcup = { + enable = mkEnableOption "Profile for Netcup VM"; + }; + + config = mkIf config.profiles.clerie.netcup.enable { + + services.qemuGuest.enable = true; + + # https://helpcenter.netcup.com/de/wiki/server/nameserver/ + networking.nameservers = [ "2a03:4000:0:1::e1e6" "2a03:4000:8000::fce6" "46.38.255.230" "46.38.252.230" ]; + + }; + +}