declarative-nm: remove with lib;
This commit is contained in:
parent
836159960c
commit
3b0d577f3b
@ -4,12 +4,11 @@
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
# from: https://discourse.nixos.org/t/imperative-declarative-wifi-networks-with-wpa-supplicant/12394/6
|
||||
let
|
||||
cfg = config.networking.networkmanager;
|
||||
|
||||
getFileName = stringAsChars (x: if x == " " then "-" else x);
|
||||
getFileName = lib.stringAsChars (x: if x == " " then "-" else x);
|
||||
|
||||
createWifi = ssid: opt: {
|
||||
name = "NetworkManager/system-connections/${getFileName ssid}.nmconnection";
|
||||
@ -24,21 +23,21 @@ let
|
||||
ssid=${ssid}
|
||||
|
||||
[wifi-security]
|
||||
${optionalString (opt.psk != null) ''
|
||||
${lib.optionalString (opt.psk != null) ''
|
||||
key-mgmt=wpa-psk
|
||||
psk=${opt.psk}''}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
keyFiles = mapAttrs' createWifi config.networking.wireless.networks;
|
||||
keyFiles = lib.mapAttrs' createWifi config.networking.wireless.networks;
|
||||
in
|
||||
{
|
||||
config = mkIf cfg.enable {
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.etc = keyFiles;
|
||||
|
||||
systemd.services.NetworkManager-predefined-connections = {
|
||||
restartTriggers = mapAttrsToList (name: value: value.source) keyFiles;
|
||||
restartTriggers = lib.mapAttrsToList (name: value: value.source) keyFiles;
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user