From 6cf831a3474a5b9970b676efa5e8f67d35bc9ca0 Mon Sep 17 00:00:00 2001 From: Daniel Olsen Date: Fri, 3 Mar 2023 22:28:26 +0100 Subject: [PATCH] switch to networkd --- base.nix | 14 ++++++++------ flake.lock | 30 +++++++++++++++--------------- hosts/bekkalokk/configuration.nix | 15 +++------------ hosts/ildkule/configuration.nix | 20 +++----------------- hosts/jokum/configuration.nix | 27 +++------------------------ values.nix | 9 +++++++++ 6 files changed, 41 insertions(+), 74 deletions(-) diff --git a/base.nix b/base.nix index 8bcf92e..7681700 100644 --- a/base.nix +++ b/base.nix @@ -5,13 +5,15 @@ ./users ]; - networking.domain = "pvv.ntnu.no"; - networking.useDHCP = false; - networking.search = [ "pvv.ntnu.no" "pvv.org" ]; - networking.nameservers = lib.mkDefault [ "129.241.0.200" "129.241.0.201" ]; - networking.tempAddresses = lib.mkDefault "disabled"; - networking.defaultGateway = values.hosts.gateway; + # networking.domain = "pvv.ntnu.no"; + # networking.useDHCP = false; + # networking.search = [ "pvv.ntnu.no" "pvv.org" ]; + # networking.nameservers = lib.mkDefault [ "129.241.0.200" "129.241.0.201" ]; + # networking.tempAddresses = lib.mkDefault "disabled"; + # networking.defaultGateway = values.hosts.gateway; + systemd.network.enable = true; + services.resolved = { enable = lib.mkDefault true; dnssec = "false"; # Supposdly this keeps breaking and the default is to allow downgrades anyways... diff --git a/flake.lock b/flake.lock index e81a9fc..0898baf 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1674198693, - "narHash": "sha256-xjIJ4LinPNbV+0UYwhCldWUiL1e/B+hN4SR8cxOvxZA=", + "lastModified": 1676674799, + "narHash": "sha256-NaZWOgNrco5OT0J5VrWg02SCkKz8RV1sxRjh0/MWMEc=", "owner": "dali99", "repo": "nixos-matrix-modules", - "rev": "07e95170e8887b918c288c9751e46d3e0b6ab34f", + "rev": "362496f4aacb680406db3fad36f98d38e8285b30", "type": "github" }, "original": { @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1676238723, - "narHash": "sha256-081ya+i6yuVJLDH5UeYcz+5BHKA3IKQw7pk7aqkpLQw=", + "lastModified": 1677779205, + "narHash": "sha256-6DBjL9wjq86p2GczmwnHtFRnWPBPItc67gapWENBgX8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "38b81240fc7b2edad94951993f1e4f9f5cedb563", + "rev": "96e18717904dfedcd884541e5a92bf9ff632cf39", "type": "github" }, "original": { @@ -51,11 +51,11 @@ }, "nixpkgs-stable": { "locked": { - "lastModified": 1676162277, - "narHash": "sha256-GK3cnvKNo1l0skGYXXiLJ/TLqdKyIYXd7jOlo0gN+Qw=", + "lastModified": 1677560965, + "narHash": "sha256-Tqwt5alTtMnbYUPKCYRYZqlfbjprLgDWqjMhXpFMQ6k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "d863ca850a06d91365c01620dcac342574ecf46f", + "rev": "40968a3aa489191cf4b7ba85cf2a54d8a75c8daa", "type": "github" }, "original": { @@ -81,11 +81,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1676171095, - "narHash": "sha256-2laeSjBAAJ9e/C3uTIPb287iX8qeVLtWiilw1uxqG+A=", + "lastModified": 1677833841, + "narHash": "sha256-yHZFGe7dhBE43FFWKiWc29NuveH+nfyTT6oKyFDEMys=", "owner": "Mic92", "repo": "sops-nix", - "rev": "c5dab21d8706afc7ceb05c23d4244dcb48d6aade", + "rev": "128e9b29ddd88ceb634a28f7dbbfee7b895f005f", "type": "github" }, "original": { @@ -96,11 +96,11 @@ }, "unstable": { "locked": { - "lastModified": 1676243402, - "narHash": "sha256-BLVAH4iXKlWr7tLG6f+amAaMHPA55xWpJTS4MdBLRf0=", + "lastModified": 1677845674, + "narHash": "sha256-9wy/QFibdJUp7WQUe50U5bZKocg3OOHBpJhpl5ddfbE=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "14b15a92dcd28a5eea0122f03b31f7f17e816420", + "rev": "dcc47fef8bd1e91baeab8fb34a35337ab8f3a3fd", "type": "github" }, "original": { diff --git a/hosts/bekkalokk/configuration.nix b/hosts/bekkalokk/configuration.nix index f48cbc9..90b5d48 100644 --- a/hosts/bekkalokk/configuration.nix +++ b/hosts/bekkalokk/configuration.nix @@ -22,18 +22,9 @@ networking.hostName = "bekkalokk"; - networking.interfaces.ens33 = { - useDHCP = false; - - ipv4.addresses = [{ - address = values.hosts.bekkalokk.ipv4; - prefixLength = 25; - }]; - - ipv6.addresses = [{ - address = values.hosts.bekkalokk.ipv6; - prefixLength = 64; - }]; + systemd.network.networks."30-ens33" = values.defaultNetworkConfig // { + matchConfig.Name = "ens33"; + address = with values.hosts.ildkule; [ (ipv4 + "/25") (ipv6 + "/64") ]; }; # Do not change, even during upgrades. diff --git a/hosts/ildkule/configuration.nix b/hosts/ildkule/configuration.nix index 15bf2d5..3da4a33 100644 --- a/hosts/ildkule/configuration.nix +++ b/hosts/ildkule/configuration.nix @@ -20,23 +20,9 @@ networking.hostName = "ildkule"; # Define your hostname. - networking.interfaces.ens18.useDHCP = false; - - networking.interfaces.ens18.ipv4 = { - addresses = [ - { - address = values.hosts.ildkule.ipv4; - prefixLength = 25; - } - ]; - }; - networking.interfaces.ens18.ipv6 = { - addresses = [ - { - address = values.hosts.ildkule.ipv6; - prefixLength = 64; - } - ]; + systemd.network.networks."30-ens18" = values.defaultNetworkConfig // { + matchConfig.Name = "ens18"; + address = with values.hosts.ildkule; [ (ipv4 + "/25") (ipv6 + "/64") ]; }; # List packages installed in system profile diff --git a/hosts/jokum/configuration.nix b/hosts/jokum/configuration.nix index 6a6bd52..6c69ec8 100644 --- a/hosts/jokum/configuration.nix +++ b/hosts/jokum/configuration.nix @@ -22,30 +22,9 @@ services.resolved.enable = false; - networking.interfaces.ens10f1.useDHCP = false; - networking.interfaces.ens10f1.ipv4 = { - addresses = [ - { - address = values.hosts.jokum.ipv4; - prefixLength = 25; - } - { - address = values.services.turn.ipv4; - prefixLength = 25; - } - ]; - }; - networking.interfaces.ens10f1.ipv6 = { - addresses = [ - { - address = values.hosts.jokum.ipv6; - prefixLength = 64; - } - { - address = values.services.turn.ipv6; - prefixLength = 64; - } - ]; + systemd.network.networks."30-ens10f1" = values.defaultNetworkConfig // { + matchConfig.Name = "ens10f1"; + address = with values.hosts.jokum; [ (ipv4 + "/25") (ipv6 + "/64") ]; }; # List packages installed in system profile diff --git a/values.nix b/values.nix index 68ebeb2..6849f89 100644 --- a/values.nix +++ b/values.nix @@ -34,4 +34,13 @@ in rec { ipv6 = pvv-ipv6 209; }; }; + + defaultNetworkConfig = { + networkConfig.IPv6AcceptRA = "no"; + gateway = [ hosts.gateway ]; + dns = [ "129.241.0.200" "129.241.0.201" ]; + domains = [ "pvv.ntnu.no" "pvv.org" ]; + DHCP = "no"; + }; + }