This commit is contained in:
mjallen18
2026-03-30 15:38:25 -05:00
parent a673f379c7
commit 8d8d49bd38

View File

@@ -49,8 +49,35 @@ let
psk = profile.psk; 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 in
mapAttrs' make cfg.networkmanager.profiles; userProfiles // ethernetProfile;
in in
{ {
imports = [ imports = [
@@ -173,8 +200,8 @@ in
networkmanager-vpnc networkmanager-vpnc
]; ];
# Configure WiFi profiles if any are defined # Configure profiles if any are defined
ensureProfiles = mkIf (cfg.networkmanager.profiles != { }) { ensureProfiles = mkIf (profiles != { }) {
environmentFiles = lib.optional (config.sops.secrets ? wifi) config.sops.secrets.wifi.path; environmentFiles = lib.optional (config.sops.secrets ? wifi) config.sops.secrets.wifi.path;
profiles = profiles; profiles = profiles;
}; };