diff --git a/hosts/g2/configuration.nix b/hosts/g2/configuration.nix index ed41ac9..f98820f 100644 --- a/hosts/g2/configuration.nix +++ b/hosts/g2/configuration.nix @@ -6,7 +6,14 @@ ./hardware-configuration.nix ../modules/nasp.nix ]; - nasp.serial = 2; + nasp = { + serial = 2; + network = { + eth0Name = "eno1"; + eth1Name = "eno2"; + eth2Name = "enp2s0np0"; + }; + }; boot.supportedFilesystems = [ "zfs" ]; boot.zfs.forceImportRoot = false; networking.hostId = "b500d22c"; diff --git a/hosts/modules/nasp.nix b/hosts/modules/nasp.nix index b95dc48..95787a7 100644 --- a/hosts/modules/nasp.nix +++ b/hosts/modules/nasp.nix @@ -2,6 +2,7 @@ let mainCfg = config.nasp; + networkCfg = mainCfg.network; hostName = ("g" + (builtins.toString mainCfg.serial)); ipSuffix = (builtins.toString (mainCfg.serial + 100)); dnew = (pkgs.writeShellScriptBin "dnew" (builtins.readFile ./scripts/dnew)); @@ -12,6 +13,20 @@ in type = lib.types.int; description = "Serial of the machine (gX)"; }; + network = { + eth0Name = lib.mkOption { + type = lib.types.str; + description = "Name of eth0 (192.168.16.0/24)"; + }; + eth1Name = lib.mkOption { + type = lib.types.str; + description = "Name of eth1 (thunet)"; + }; + eth2Name = lib.mkOption { + type = lib.types.str; + description = "Name of the RoCE NIC"; + }; + }; }; # inplementation @@ -40,41 +55,45 @@ in ## networking networking.nameservers = [ "192.168.16.118" ]; services.resolved.enable = true; - networking.networkmanager.enable = true; - networking.interfaces = { - eno1.wakeOnLan.enable = true; - eno1.useDHCP = true; - eno1.ipv4 = { - addresses = [ - { - address = "192.168.16.${ipSuffix}"; - prefixLength = 24; - } - ]; - routes = [ - { - address = "0.0.0.0"; - prefixLength = 0; - via = "192.168.16.118"; - options = { metric = "90"; }; - } - ]; + networking.networkmanager.enable = false; + networking.useDHCP = false; + systemd.network.enable = true; + systemd.network.networks."10-eth0" = { + matchConfig.Name = networkCfg.eth0Name; + networkConfig = { + DHCP = "no"; + IPv6AcceptRA = true; }; - eno1.ipv6.routes = [ + address = [ "192.168.16.${ipSuffix}/24" ]; + routes = [ { - address = "::"; - prefixLength = 0; - via = "fe80::2eea:7fff:feec:4689"; - options = { metric = "90"; }; + routeConfig = { + Gateway = "192.168.16.118"; + GatewayOnLink = true; + Metric = 90; + }; } - ]; - enp2s0np0.ipv4.addresses = [ { - address = "12.12.12.${ipSuffix}"; - prefixLength = 24; + routeConfig = { + Gateway = "2001:da8:bf:300::1"; + GatewayOnLink = true; + Metric = 90; + }; } ]; }; + systemd.network.networks."10-eth1" = { + matchConfig.Name = networkCfg.eth1Name; + networkConfig = { + DHCP = "yes"; + IPv6AcceptRA = true; + }; + }; + systemd.network.networks."10-eth2" = { + matchConfig.Name = networkCfg.eth2Name; + address = [ "12.12.12.${ipSuffix}/24" ]; + }; + networking.interfaces.eno1.wakeOnLan.enable = true; networking.extraHosts = '' 192.168.16.101 g1-nasp g1 192.168.16.102 g2-nasp g2 @@ -106,7 +125,7 @@ in }; networking.rxe = { enable = true; - interfaces = [ "enp2s0np0" ]; + interfaces = [ "${networkCfg.eth2Name}" ]; }; ## packages and services nixpkgs.config.allowUnfree = true;