From 543611983cd66449378ada55e33d6d0bff7a6e55 Mon Sep 17 00:00:00 2001 From: chayleaf Date: Fri, 12 Jul 2024 03:37:03 +0700 Subject: [PATCH] server: switch to systemd-networkd --- system/devices/radxa-rock5a-server.nix | 22 ++++++++++++++++------ system/hosts/router/default.nix | 1 + system/hosts/router/options.nix | 5 +++++ 3 files changed, 22 insertions(+), 6 deletions(-) diff --git a/system/devices/radxa-rock5a-server.nix b/system/devices/radxa-rock5a-server.nix index aee4438..04560c9 100644 --- a/system/devices/radxa-rock5a-server.nix +++ b/system/devices/radxa-rock5a-server.nix @@ -35,8 +35,6 @@ in "net.ipv4.tcp_congestion_control" = "bbr"; }; - networking.useDHCP = true; - /* # as expected, systemd initrd and networking didn't work well, and i really cba to debug it networking.useDHCP = false; networking.useNetworkd = true; @@ -52,8 +50,18 @@ in networks."10-dhcp" = { DHCP = "yes"; name = "e*"; + networkConfig = { + IPv6AcceptRA = "yes"; + }; + dhcpV4Config = { + ClientIdentifier = "mac"; + DUIDType = "link-layer"; + }; + dhcpV6Config = { + DUIDType = "link-layer"; + }; }; - };*/ + }; boot.initrd = { /*systemd = { @@ -79,10 +87,12 @@ in preLVMCommands = lib.mkOrder 499 '' ip link set end0 address ${router-config.router-settings.serverInitrdMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true ''; - postMountCommands = '' - ip link set end0 address ${router-config.router-settings.serverMac} || ip link set eth0 address ${router-config.router-settings.serverInitrdMac} || true - ''; + # postMountCommands = '' + # ip link set end0 address ${router-config.router-settings.serverMac} || ip link set eth0 address ${router-config.router-settings.serverMac} || true + # ''; network.enable = true; + network.flushBeforeStage2 = true; + network.udhcpc.enable = true; network.udhcpc.extraArgs = [ "-t100" ]; network.ssh = { enable = true; diff --git a/system/hosts/router/default.nix b/system/hosts/router/default.nix index 3b055a0..56a828a 100644 --- a/system/hosts/router/default.nix +++ b/system/hosts/router/default.nix @@ -296,6 +296,7 @@ in { { ipAddress = lightBulbAddress6; macAddress = cfg.lightBulbMac; } { ipAddress = serverInitrdAddress6; + duid = cfg.serverInitrdDuid; macAddress = cfg.serverInitrdMac; } ]; diff --git a/system/hosts/router/options.nix b/system/hosts/router/options.nix index d9ebb74..8903091 100644 --- a/system/hosts/router/options.nix +++ b/system/hosts/router/options.nix @@ -70,6 +70,11 @@ description = "server's mac address in initrd"; type = lib.types.str; }; + serverInitrdDuid = lib.mkOption { + description = "server's duid in initrd"; + type = with lib.types; nullOr str; + default = null; + }; vacuumMac = lib.mkOption { description = "robot vacuum's mac address"; type = lib.types.str;