stuff
This commit is contained in:
@@ -7,6 +7,45 @@
|
||||
with lib;
|
||||
let
|
||||
cfg = config.${namespace}.network;
|
||||
|
||||
profiles =
|
||||
let
|
||||
make =
|
||||
name: profile:
|
||||
nameValuePair "${name}" {
|
||||
connection = {
|
||||
id = name;
|
||||
type = profile.type;
|
||||
autoconnect = profile.autoconnect;
|
||||
autoconnect-retries = profile.autoconnect-retries;
|
||||
autoconnect-priority = profile.priority;
|
||||
interface-name = cfg.ipv4.interface;
|
||||
};
|
||||
ipv4 =
|
||||
{
|
||||
method = cfg.ipv4.method;
|
||||
} // (if (cfg.ipv4.method == "auto") then { }
|
||||
else
|
||||
{
|
||||
address = cfg.ipv4.address;
|
||||
gateway = cfg.ipv4.gateway;
|
||||
dns = cfg.ipv4.dns;
|
||||
});
|
||||
ipv6 = {
|
||||
addr-gen-mode = "stable-privacy";
|
||||
method = "auto";
|
||||
};
|
||||
wifi = mkIf (profile.type == "wifi") {
|
||||
mode = "infrastructure";
|
||||
ssid = profile.ssid;
|
||||
};
|
||||
wifi-security = mkIf (profile.type == "wifi") {
|
||||
key-mgmt = profile.keyMgmt;
|
||||
psk = profile.psk;
|
||||
};
|
||||
};
|
||||
in
|
||||
mapAttrs' make cfg.networkmanager.profiles;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
@@ -75,47 +114,18 @@ in
|
||||
})
|
||||
|
||||
# Enable NetworkManager when wifi is enabled and iwd is disabled
|
||||
(mkIf (cfg.wifi.enable && !cfg.iwd.enable) {
|
||||
(mkIf (cfg.networkmanager.enable && !cfg.iwd.enable) {
|
||||
enable = true;
|
||||
wifi.powersave = cfg.wifi.powersave;
|
||||
wifi.powersave = cfg.networkmanager.powersave;
|
||||
settings.connectivity.uri = mkDefault "http://nmcheck.gnome.org/check_network_status.txt";
|
||||
|
||||
# Configure WiFi profiles if any are defined
|
||||
ensureProfiles = mkIf (cfg.wifi.profiles != { }) {
|
||||
ensureProfiles = mkIf (cfg.networkmanager.profiles != { }) {
|
||||
environmentFiles = [
|
||||
config.sops.secrets.wifi.path
|
||||
];
|
||||
|
||||
profiles = mapAttrs (name: profile: {
|
||||
connection = {
|
||||
id = name;
|
||||
type = "wifi";
|
||||
};
|
||||
ipv4 =
|
||||
if (cfg.ipv4.method == "auto") then
|
||||
{
|
||||
method = "auto";
|
||||
}
|
||||
else
|
||||
{
|
||||
address1 = cfg.ipv4.address;
|
||||
dns = cfg.ipv4.dns;
|
||||
gateway = cfg.ipv4.gateway;
|
||||
method = "manual";
|
||||
};
|
||||
ipv6 = {
|
||||
addr-gen-mode = "stable-privacy";
|
||||
method = "auto";
|
||||
};
|
||||
wifi = {
|
||||
mode = "infrastructure";
|
||||
ssid = profile.ssid;
|
||||
};
|
||||
wifi-security = {
|
||||
key-mgmt = profile.keyMgmt;
|
||||
psk = profile.psk;
|
||||
};
|
||||
}) cfg.wifi.profiles;
|
||||
profiles = profiles;
|
||||
};
|
||||
})
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user