wifi: move to ensureProfiles
This commit is contained in:
@@ -11,7 +11,6 @@
|
|||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
imports = [
|
imports = [
|
||||||
./declarative-nm.nix
|
|
||||||
# ./vm.nix
|
# ./vm.nix
|
||||||
./steam.nix
|
./steam.nix
|
||||||
./networking.nix
|
./networking.nix
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
{
|
|
||||||
config,
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
...
|
|
||||||
}:
|
|
||||||
# from: https://discourse.nixos.org/t/imperative-declarative-wifi-networks-with-wpa-supplicant/12394/6
|
|
||||||
let
|
|
||||||
cfg = config.networking.networkmanager;
|
|
||||||
|
|
||||||
getFileName = lib.stringAsChars (x: if x == " " then "-" else x);
|
|
||||||
|
|
||||||
createWifi = ssid: opt: {
|
|
||||||
name = "NetworkManager/system-connections/${getFileName ssid}.nmconnection";
|
|
||||||
value = {
|
|
||||||
mode = "0400";
|
|
||||||
source = pkgs.writeText "${ssid}.nmconnection" ''
|
|
||||||
[connection]
|
|
||||||
id=${ssid}
|
|
||||||
type=wifi
|
|
||||||
|
|
||||||
[wifi]
|
|
||||||
ssid=${ssid}
|
|
||||||
|
|
||||||
[wifi-security]
|
|
||||||
${lib.optionalString (opt.psk != null) ''
|
|
||||||
key-mgmt=wpa-psk
|
|
||||||
psk=${opt.psk}''}
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
keyFiles = lib.mapAttrs' createWifi config.networking.wireless.networks;
|
|
||||||
in
|
|
||||||
{
|
|
||||||
config = lib.mkIf cfg.enable {
|
|
||||||
environment.etc = keyFiles;
|
|
||||||
|
|
||||||
systemd.services.NetworkManager-predefined-connections = {
|
|
||||||
restartTriggers = lib.mapAttrsToList (name: value: value.source) keyFiles;
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
RemainAfterExit = true;
|
|
||||||
ExecStart = "${pkgs.coreutils}/bin/true";
|
|
||||||
ExecReload = "${pkgs.networkmanager}/bin/nmcli connection reload";
|
|
||||||
};
|
|
||||||
reloadIfChanged = true;
|
|
||||||
wantedBy = [ "multi-user.target" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -19,8 +19,8 @@
|
|||||||
# fix suspend issue
|
# fix suspend issue
|
||||||
powersave = false;
|
powersave = false;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
wireless.networks = import ./secrets/wifi-passwords.nix;
|
ensureProfiles.profiles = import ./secrets/wifi-passwords.nix;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Reference in New Issue
Block a user