summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2021-02-19 19:56:19 +0100
committerMaximilian Bosch <maximilian@mbosch.me>2021-04-16 13:18:25 +0200
commitde0a39166b622f9d4526a920db835619e90522bf (patch)
tree4c1729a3b5b07cd52554339bb0bb7d10273904e2 /nixos
parent98d6b081d12ebe7e443e62c40ebaeeddbe5bb9fc (diff)
downloadnixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar.gz
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar.bz2
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar.lz
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar.xz
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.tar.zst
nixpkgs-de0a39166b622f9d4526a920db835619e90522bf.zip
wpa_supplicant: allow both imperative and declarative networks
For a while now it's possible to specify an additional config file in
`wpa_supplicant`[1]. In contrast to the file specified via `-c` this was
supposed to be used for immutable settings and not e.g. additional
networks.

However I'm a little bit unhappy about the fact that one has to choose
between a fully imperative setup and a fully declarative one where the
one would have to write credentials for e.g. WPA2-enterprise networks
into the store.

The primary problem with the current state of `wpa_supplicant` is that
if the `SAVE_CONFIG` command is invoked (e.g. via `wpa_cli`), all known
networks will be written to `/etc/wpa_supplicant.conf` and thus all
declarative networks would get out of sync with the declarative
settings.

To work around this, I had to change the following things:

* The `networking.wireless`-module now uses `-I` for declarative config,
  so the user-controlled mode can be used along with the
  `networks`-option.

* I added an `ro`-field to the `ssid`-struct in the
  `wpa_supplicant`-sources. This will be set to `1` for each network
  specified in the config passed via `-I`.

  Whenever config is written to the disk, those networks will be
  skipped, so changes to declarative networks are only temporary.

[1] https://w1.fi/cgit/hostap/commit/wpa_supplicant?id=e6304cad47251e88d073553042f1ea7805a858d1
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/networking/wpa_supplicant.nix2
1 files changed, 1 insertions, 1 deletions
diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix
index 61482596763..75a8cdef603 100644
--- a/nixos/modules/services/networking/wpa_supplicant.nix
+++ b/nixos/modules/services/networking/wpa_supplicant.nix
@@ -236,7 +236,7 @@ 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 ${configFile}"
+        iface_args="-s -u -D${cfg.driver} -c /etc/wpa_supplicant.conf -I ${configFile}"
         ${if ifaces == [] then ''
           for i in $(cd /sys/class/net && echo *); do
             DEVTYPE=