diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-04-15 18:13:18 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-04-16 13:18:46 +0200 |
commit | 08ced9d67f579684c4886acb696ee79e9e27303b (patch) | |
tree | b4b591571214cc6d32657ff02cb3b496a08d525b /nixos | |
parent | de0a39166b622f9d4526a920db835619e90522bf (diff) | |
download | nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar.gz nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar.bz2 nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar.lz nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar.xz nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.tar.zst nixpkgs-08ced9d67f579684c4886acb696ee79e9e27303b.zip |
nixos/wpa_supplicant: make new behavior opt-in
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/networking/wpa_supplicant.nix | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix index 75a8cdef603..98cc906de5c 100644 --- a/nixos/modules/services/networking/wpa_supplicant.nix +++ b/nixos/modules/services/networking/wpa_supplicant.nix @@ -3,6 +3,10 @@ with lib; let + package = if cfg.allowDeclarativeAndImperativeNetworks + then pkgs.wpa_supplicant_ro_ssids + else pkgs.wpa_supplicant; + cfg = config.networking.wireless; configFile = if cfg.networks != {} || cfg.extraConfig != "" || cfg.userControlled.enable then pkgs.writeText "wpa_supplicant.conf" '' ${optionalString cfg.userControlled.enable '' @@ -47,6 +51,16 @@ in { description = "Force a specific wpa_supplicant driver."; }; + allowDeclarativeAndImperativeNetworks = mkEnableOption "support for imperative & declarative networks" // { + description = '' + Whether to allow configuring networks "imperatively" (e.g. via + <package>wpa_supplicant_gui</package>) and declaratively via + <xref linkend="opt-networking.wireless.networks" />. + + Please note that this adds a custom patch to <package>wpa_supplicant</package>. + ''; + }; + networks = mkOption { type = types.attrsOf (types.submodule { options = { @@ -211,9 +225,9 @@ in { message = ''options networking.wireless."${name}".{psk,pskRaw,auth} are mutually exclusive''; }); - environment.systemPackages = [ pkgs.wpa_supplicant ]; + environment.systemPackages = [ package ]; - services.dbus.packages = [ pkgs.wpa_supplicant ]; + services.dbus.packages = [ package ]; services.udev.packages = [ pkgs.crda ]; # FIXME: start a separate wpa_supplicant instance per interface. @@ -230,13 +244,17 @@ in { wantedBy = [ "multi-user.target" ]; stopIfChanged = false; - path = [ pkgs.wpa_supplicant ]; + path = [ package ]; - script = '' + script = let + configStr = if cfg.allowDeclarativeAndImperativeNetworks + then "-c /etc/wpa_supplicant.conf -I ${configFile}" + else "-c ${configFile}"; + in '' if [ -f /etc/wpa_supplicant.conf -a "/etc/wpa_supplicant.conf" != "${configFile}" ] then echo >&2 "<3>/etc/wpa_supplicant.conf present but ignored. Generated ${configFile} is used instead." fi - iface_args="-s -u -D${cfg.driver} -c /etc/wpa_supplicant.conf -I ${configFile}" + iface_args="-s -u -D${cfg.driver} ${configStr}" ${if ifaces == [] then '' for i in $(cd /sys/class/net && echo *); do DEVTYPE= |