From 8d8d49bd38fe0e9cb5fa7e7bb3b48df29ef57249 Mon Sep 17 00:00:00 2001 From: mjallen18 Date: Mon, 30 Mar 2026 15:38:25 -0500 Subject: [PATCH] net --- modules/nixos/network/default.nix | 33 ++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/modules/nixos/network/default.nix b/modules/nixos/network/default.nix index e8b0fae..c75f511 100644 --- a/modules/nixos/network/default.nix +++ b/modules/nixos/network/default.nix @@ -49,8 +49,35 @@ let psk = profile.psk; }; }; + + userProfiles = mapAttrs' make cfg.networkmanager.profiles; + + # When using manual IP with NM enabled, auto-generate an ethernet profile + # so NM actually assigns the static address (not just DHCP). + ethernetProfile = + optionalAttrs (cfg.ipv4.method == "manual" && cfg.ipv4.interface != "" && cfg.networkmanager.enable) + { + "static-${cfg.ipv4.interface}" = { + connection = { + id = "static-${cfg.ipv4.interface}"; + type = "ethernet"; + autoconnect = true; + interface-name = cfg.ipv4.interface; + }; + ipv4 = { + method = "manual"; + address = cfg.ipv4.address; + gateway = cfg.ipv4.gateway; + dns = cfg.ipv4.dns; + }; + ipv6 = { + addr-gen-mode = "stable-privacy"; + method = "auto"; + }; + }; + }; in - mapAttrs' make cfg.networkmanager.profiles; + userProfiles // ethernetProfile; in { imports = [ @@ -173,8 +200,8 @@ in networkmanager-vpnc ]; - # Configure WiFi profiles if any are defined - ensureProfiles = mkIf (cfg.networkmanager.profiles != { }) { + # Configure profiles if any are defined + ensureProfiles = mkIf (profiles != { }) { environmentFiles = lib.optional (config.sops.secrets ? wifi) config.sops.secrets.wifi.path; profiles = profiles; };