diff --git a/nixos/machines/ghatanothoa/configuration.nix b/nixos/machines/ghatanothoa/configuration.nix index 57cc0cb..8364bea 100644 --- a/nixos/machines/ghatanothoa/configuration.nix +++ b/nixos/machines/ghatanothoa/configuration.nix @@ -4,6 +4,7 @@ ../../modules/jitsi.nix ../../roles ../../roles/vm.nix + ../../modules/vmNetwork.nix ]; services.mathebau-jitsi = { @@ -13,5 +14,6 @@ # System configuration here networking.hostName = "ghatanothoa"; + vmNetwork.ipv4 = "192.168.0.25"; system.stateVersion = "23.11"; } diff --git a/nixos/machines/lobon/configuration.nix b/nixos/machines/lobon/configuration.nix index e0662be..6cb371a 100644 --- a/nixos/machines/lobon/configuration.nix +++ b/nixos/machines/lobon/configuration.nix @@ -4,6 +4,7 @@ ../../modules/mailman.nix ../../roles ../../roles/vm.nix + ../../modules/vmNetwork.nix ]; # System configuration here @@ -15,6 +16,7 @@ }; networking.hostName = "lobon"; + vmNetwork.ipv4 = "192.168.0.22"; system.stateVersion = "23.11"; sops.secrets = { diff --git a/nixos/machines/nodens/configuration.nix b/nixos/machines/nodens/configuration.nix index a9ae8a2..554e407 100644 --- a/nixos/machines/nodens/configuration.nix +++ b/nixos/machines/nodens/configuration.nix @@ -3,6 +3,7 @@ ./hardware-configuration.nix ../../roles ../../roles/vm.nix + ../../modules/vmNetwork.nix ]; # System configuration here @@ -10,5 +11,6 @@ environment.systemPackages = [pkgs.git]; networking.hostName = "nodens"; + vmNetwork.ipv4 = "192.168.0.18"; system.stateVersion = "24.11"; } diff --git a/nixos/machines/nyarlathotep/configuration.nix b/nixos/machines/nyarlathotep/configuration.nix index 88bb1b0..57d00ff 100644 --- a/nixos/machines/nyarlathotep/configuration.nix +++ b/nixos/machines/nyarlathotep/configuration.nix @@ -4,6 +4,7 @@ ../../modules/mail.nix ../../roles ../../roles/vm.nix + ../../modules/vmNetwork.nix ]; # System configuration here @@ -39,6 +40,7 @@ }; networking.hostName = "nyarlathotep"; + vmNetwork.ipv4 = "192.168.0.17"; system.stateVersion = "24.05"; sops.secrets = let diff --git a/nixos/modules/mail.nix b/nixos/modules/mail.nix index 5384c40..b8e51f1 100644 --- a/nixos/modules/mail.nix +++ b/nixos/modules/mail.nix @@ -360,7 +360,7 @@ in { # We don't want this in order to not need to persist borg cache and simplify new deployments. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes"; }; - repo = "borg@bragi:nyarlathotep"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33 + repo = "borg@192.168.1.11:nyarlathotep"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33 startAt = "daily"; user = "root"; group = "root"; diff --git a/nixos/modules/mailman.nix b/nixos/modules/mailman.nix index 5383374..66ee109 100644 --- a/nixos/modules/mailman.nix +++ b/nixos/modules/mailman.nix @@ -117,7 +117,7 @@ in { # We don't want this in order to not need to persist borg cache and simplify new deployments. BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK = "yes"; }; - repo = "borg@bragi:lobon"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33 + repo = "borg@192.168.1.11:lobon"; # TODO for https://gitea.mathebau.de/Fachschaft/nixConfig/issues/33 startAt = "daily"; user = "root"; group = "root"; diff --git a/nixos/modules/vmNetwork.nix b/nixos/modules/vmNetwork.nix new file mode 100644 index 0000000..133d101 --- /dev/null +++ b/nixos/modules/vmNetwork.nix @@ -0,0 +1,48 @@ +{ + lib, + config, + ... +}: let + inherit + (lib) + mkOption + types + last + init + ; + inherit + (lib.strings) + splitString + concatStringsSep + toInt + ; + cfg = config.vmNetwork; +in { + imports = []; + + options.vmNetwork = { + ipv4 = mkOption { + type = types.str; + description = "the ipv4 adress of this machine"; + }; + }; + + config = { + networking = { + interfaces.enX0.ipv4.addresses = [ + { + address = cfg.ipv4; + prefixLength = 16; + } + ]; + defaultGateway = let + addr = splitString "." cfg.ipv4; + addrInit = init addr; + addrLastInt = builtins.toString (toInt (last addr) + 127); + in + concatStringsSep "." (addrInit ++ [addrLastInt]); + # https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp + nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"]; + }; + }; +} diff --git a/nixos/roles/hostmap.nix b/nixos/roles/hostmap.nix deleted file mode 100644 index 66f8615..0000000 --- a/nixos/roles/hostmap.nix +++ /dev/null @@ -1,57 +0,0 @@ -# This data is taken from /etc/hosts from azatoth -{ - bragi = { - ipv4 = "192.168.1.11"; - }; - tsathoggua = { - ipv4 = "192.168.0.13"; - }; - nyogtha = { - ipv4 = "192.168.0.14"; - }; - hastur = { - ipv4 = "192.168.0.15"; - }; - cthulhu = { - ipv4 = "192.168.0.16"; - }; - nyarlathotep = { - ipv4 = "192.168.0.17"; - }; - nodens = { - ipv4 = "192.168.0.18"; - }; - uvhash = { - ipv4 = "192.168.0.19"; - }; - aphoom-zhah = { - ipv4 = "192.168.0.20"; - }; - dagon = { - ipv4 = "192.168.0.21"; - }; - lobon = { - ipv4 = "192.168.0.22"; - }; - yibb-tstll = { - ipv4 = "192.168.0.23"; - }; - eihort = { - ipv4 = "192.168.0.24"; - }; - ghatanothoa = { - ipv4 = "192.168.0.25"; - }; - toth = { - ipv4 = "192.168.0.26"; - }; - ithaqua = { - ipv4 = "192.168.0.27"; - }; - cthugha = { - ipv4 = "192.168.0.30"; - }; - sanctamariamaterdei = { - ipv4 = "192.168.0.92"; - }; -} diff --git a/nixos/roles/vm.nix b/nixos/roles/vm.nix index aff9f22..32fba6d 100644 --- a/nixos/roles/vm.nix +++ b/nixos/roles/vm.nix @@ -1,6 +1,5 @@ {modulesPath, ...}: { imports = [ (modulesPath + "/virtualisation/xen-domU.nix") - ./vmNetwork.nix ]; } diff --git a/nixos/roles/vmNetwork.nix b/nixos/roles/vmNetwork.nix deleted file mode 100644 index d4a0ff7..0000000 --- a/nixos/roles/vmNetwork.nix +++ /dev/null @@ -1,46 +0,0 @@ -{ - lib, - config, - ... -}: let - inherit (lib) mapAttrsToList; - inherit (lib.attrsets) foldAttrs concatMapAttrs; - inherit (lib.asserts) assertMsg; - inherit (lib.lists) filter last init; - inherit (lib.strings) splitString toInt concatStringsSep; - inherit (builtins) elem toString; - hostmap = import ./hostmap.nix; - myhostName = config.networking.hostName; - # To turn the hostmap around suitable for networking.hosts the following simple code almost works - # concatMapAttrs (hostname: ipData: { ${ipData.ipv4} = [hostname]; }) hostmap - # but breaks as soon as we want to map two different names to the same ip. - # So the code looks uglier than one would expect. - globalhosts = foldAttrs (a: b: a ++ b) [] (mapAttrsToList (hostname: ipData: {${ipData.ipv4} = [hostname];}) hostmap); - # We replace our own ip with 127.0.0.1 in /etc/hosts - myhosts = concatMapAttrs (ip: hosts: - if (elem myhostName hosts) - # nixos maps the hostname to the loopback 127.0.0.2 by default, so we exclude it here. - # there is also a default localhost to 127.0.0.1 in place - then {"127.0.0.1" = filter (x: x != myhostName) hosts;} - else {${ip} = hosts;}) - globalhosts; - myIp = assert (assertMsg (hostmap ? ${myhostName}.ipv4) "${myhostName} has no ip configured in nixos/roles/hostmap.nix"); hostmap.${myhostName}.ipv4; -in { - networking = { - hosts = myhosts; - interfaces.enX0.ipv4.addresses = [ - { - address = myIp; - prefixLength = 16; - } - ]; - defaultGateway = let - addr = splitString "." myIp; - addrInit = init addr; - addrLastInt = toString (toInt (last addr) + 127); - in - concatStringsSep "." (addrInit ++ [addrLastInt]); - # https://www.hrz.tu-darmstadt.de/services/it_services/nameserver_dns/index.de.jsp - nameservers = ["130.83.22.63" "130.83.22.60" "130.83.56.60"]; - }; -}