Commit Graph

75 Commits

Author SHA1 Message Date
nicoo
a351c9b530 nixos/wpa_supplicant: Ensure the generated config isn't world-readable
Otherwise, `environmentFile` cannot be used to pass secrets in.
2023-12-09 21:33:55 +00:00
Robin Gloster
e5d552f5b9
treewide: update globin's maintainership 2023-10-24 13:09:45 +02:00
rnhmjoj
688d658a96
nixos/wireless: fix failure on missing config file
This change prevents doing the secret substitution when the config is
missing, which would result in an error.

The service can be useful even without configuration; for example
connman controls wpa_supplicant using dbus and as such it does not need
a config file nor any other declarative options.
2023-01-26 00:31:21 +01:00
pennae
d98322834b nixos/*: fix docbook deprecation notices
mostly no rendering changes except in buildkite, which used markdown
where docbook was expected without marking up its markdown.
2022-09-10 18:23:13 +02:00
pennae
722b99bc0e nixos/*: convert options with admonitions to MD
rendering changes only slightly, most changes are in spacing.
2022-08-31 16:36:16 +02:00
pennae
ef176dcf7e nixos/*: automatically convert option descriptions
conversions were done using https://github.com/pennae/nix-doc-munge
using (probably) rev f34e145 running

    nix-doc-munge nixos/**/*.nix
    nix-doc-munge --import nixos/**/*.nix

the tool ensures that only changes that could affect the generated
manual *but don't* are committed, other changes require manual review
and are discarded.
2022-08-31 16:32:53 +02:00
pennae
8f8e101527 nixos/*: normalize <package> to <literal>
this renders the same in the manpage and a little more clearly in the
html manual. in the manpage there continues to be no distinction from
regular text, the html manual gets code-type markup (which was probably
the intention for most of these uses anyway).
2022-08-19 22:40:58 +02:00
pennae
087472b1e5 nixos/*: automatically convert option docs 2022-08-06 20:39:12 +02:00
pennae
423545fe48 nixos/*: normalize manpage references to single-line form
now nix-doc-munge will not introduce whitespace changes when it replaces
manpage references with the MD equivalent.

no change to the manpage, changes to the HTML manual are whitespace only.
2022-08-05 18:34:50 +02:00
pennae
3aebb4a2be nixos/*: normalize link format
make (almost) all links appear on only a single line, with no
unnecessary whitespace, using double quotes for attributes. this lets us
automatically convert them to markdown easily.

the few remaining links are extremely long link in a gnome module, we'll
come back to those at a later date.
2022-08-03 21:57:46 +02:00
pennae
2e751c0772 treewide: automatically md-convert option descriptions
the conversion procedure is simple:

 - find all things that look like options, ie calls to either `mkOption`
   or `lib.mkOption` that take an attrset. remember the attrset as the
   option
 - for all options, find a `description` attribute who's value is not a
   call to `mdDoc` or `lib.mdDoc`
 - textually convert the entire value of the attribute to MD with a few
   simple regexes (the set from mdize-module.sh)
 - if the change produced a change in the manual output, discard
 - if the change kept the manual unchanged, add some text to the
   description to make sure we've actually found an option. if the
   manual changes this time, keep the converted description

this procedure converts 80% of nixos options to markdown. around 2000
options remain to be inspected, but most of those fail the "does not
change the manual output check": currently the MD conversion process
does not faithfully convert docbook tags like <code> and <package>, so
any option using such tags will not be converted at all.
2022-07-30 15:16:34 +02:00
Maximilian Bosch
fd2a89b983
nixos/wpa_supplicant: don't log that wpa_supplicant.conf is ignored with allowAuxiliaryImperativeNetworks = true
The warning is wrong with `allowAuxiliaryImperativeNetworks`[1] being
set to `true` because both files are included in this case with `-c` and
`-I`.

[1] https://nixos.org/manual/nixos/stable/options.html#opt-networking.wireless.allowAuxiliaryImperativeNetworks
2022-06-12 17:07:36 +02:00
rnhmjoj
3b8fa47f58
nixos/wireless: don't attempt fallback on WPA3 only networks 2022-02-04 08:46:32 +01:00
rnhmjoj
2eed89bbe1
nixos/wireless: implement opportunistic WPA3
It turns out it's actually possible to fall back to WPA2 in case the
authentication fails with WPA3. This was suggested to me in the hostapd
mailing list: add another network block with only WPA2 and lower
priority, for each network with WPA3. For clients with missing/broken
WPA3, wpa_supplicant will:

1. try the network block with higher priority first
2. fail and temporarily disable the network block
3. try the fallback network block and connect

This takes a little more time (still <5s) because wpa_supplicant
retries a couple times before disabling the network block, but it allows
old client to gracefully fall back to WPA2 on mixed WPA2/WPA3 networks.

To avoid downgrade attacks, clients with proper WPA3 should disable
this; in the future we may want to disable this option by default.
2022-01-14 10:54:01 +01:00
rnhmjoj
2f5ced6d7c
nixos/wireless: enable PMF by default
Alternative solution to PR #152443.
This fixes authentication failures to WPA3 networks (issue #151729)
by enabling protected management frames.
Note: old client without 802.11w support will still fail.
2022-01-09 12:29:30 +01:00
pennae
ed673a69db treewide: add defaultText for options with simple cfg.* expression defaults
adds defaultText for options with defaults that use only literals, full config.*
paths, and the cfg shortcut binding.
2021-12-09 01:14:16 +01:00
Naïm Favier
2ddc335e6f
nixos/doc: clean up defaults and examples 2021-10-04 12:47:20 +02:00
rnhmjoj
52b9dd7bf6
nixos/wpa_supplicant: add safe secret handling 2021-09-29 09:10:39 +02:00
rnhmjoj
0d082b464d
nixos/wireless: add rnhmjoj as maintainer 2021-08-13 10:16:22 +02:00
rnhmjoj
704f33c888
nixos/wireless: add one service per interface
This sets up a different systemd service for each interface. This way
each wpa_supplicant instance waits for his inteface to become ready
using the respective device unit, and that only. The configuration file
is still shared between all instances, though.

This closes a longstanding "fixme" from cbfba81.
2021-08-13 10:16:22 +02:00
rnhmjoj
bef963963a
nixos/wireless: add options for better roaming
- Add an option to automatically launch a scan when the
signal of the current network is low

- Enable 802.11r (fast access point transition) by default for all
protected networks
2021-08-12 10:11:51 +02:00
rnhmjoj
33372e8b75
nixos/wireless: generate pretty configuration
Turns this mess

    ctrl_interface=DIR=/run/wpa_supplicant GROUP=wheel
    update_config=1

    network={
      ssid="cool-network"

      psk="ciao"

    }

    network={
      ssid="fancy-network"

      eap=PEAP
    identity="user@example.com"
    password="secret"

    }

    network={
      ssid="free-network"

      key_mgmt=NONE

    }

    network={
      ssid="raw-network"

      psk=fafafa

    }

into something more human readable:

    network={
      ssid="cool-network"
      psk="ciao"
    }

    network={
      ssid="fancy-network"
      eap=PEAP
      identity="user@example.com"
      password="secret"
    }

    network={
      ssid="free-network"
      key_mgmt=NONE
    }

    network={
      ssid="raw-network"
      psk=fafafa
    }

    ctrl_interface=/run/wpa_supplicant
    ctrl_interface_group=wheel
    update_config=1
2021-08-12 10:11:51 +02:00
Martin Weinelt
41eb076ed8
Merge pull request #127595 from rnhmjoj/wpa-auto
nixos/wireless: use udev to wait for interfaces
2021-08-12 00:49:33 +02:00
rnhmjoj
99e8af51b2
nixos/wireless: use udev to wait for interfaces
I may have finally found a clean solution to the issues[1][2][3] with
the automatic discovery of wireless network interfaces.

[1]: https://github.com/NixOS/nixpkgs/issues/101963
[2]: https://github.com/NixOS/nixpkgs/issues/23196
[3]: https://github.com/NixOS/nixpkgs/pull/125917#issuecomment-856000426

Currently the start script fails right away if no interface is available
by the time it's running, possibly leaving the system without network.
This happens when running a little early in the boot. A solution is to
instead wait for at least one interface to appear before scanning the
/sys/class/net/ directory. This is done here by listening for the right
udev events (from the net/wlan subsystem) using the `udevadm monitor`
command and grep to match its output.

This methods guarantees the availability of at least one interface to
wpa_supplicant, but won't add additional interfaces once it has started.
However, if the current interface is lost, say unplugged, the service is
automatically stopped and will be restarted as soon as a one (not
necessarily the same) is detected. It would be possible make this fully
dynamic by running another service that continously listen for udev
events and manages the main wpa_supplicant daemon, but this is probably
overkill.

I tested the following cases:

  - one interface, starting at boot, w/o predictable naming scheme
  - two interfaces, starting at boot (intel wireless and a usb adapter),
    w/o predictable naming scheme
  - one interface after the system booted, w/o predictable naming scheme
  - two interfaces after the system booted, w/o predictable naming scheme
  - unplugging and plugging back the current interface
2021-08-12 00:31:06 +02:00
Guillaume Girol
407ef1dc6f
Merge pull request #121530 from symphorien/wifireg
nixos: add option to load wireless regulatory database as firmware
2021-07-27 16:43:57 +00:00
rnhmjoj
be01320a6c
nixos/wireless: only warn for no interfaces
A hard failure breaks the NixOS installer, which can't possibly
know the interface names in advance.
2021-06-08 07:42:34 +02:00
rnhmjoj
eba5f5c1e5
Revert "nixos/wireless: make wireless.interfaces mandatory"
This reverts commit 030a521adc.
2021-06-07 15:55:58 +02:00
rnhmjoj
030a521adc
nixos/wireless: make wireless.interfaces mandatory
This is the only way to solve issue #101963, for now.
2021-06-01 23:19:40 +02:00
Guillaume Girol
8fe0143d88 nixos: add option to load wireless regulatory database as firmware
use it when networkmanager or wpa_supplicant is enabled.

fixes #57053
fixes "Direct firmware load for regulatory.db failed with error -2"
in dmesg

Note that all kernels on unstable are newer that 4.15, which is required
for this to work.
2021-05-23 19:49:05 +02:00
Maximilian Bosch
84670bf681
wpa_supplicant: review fixes 2021-04-16 13:28:26 +02:00
Maximilian Bosch
08ced9d67f
nixos/wpa_supplicant: make new behavior opt-in 2021-04-16 13:18:46 +02:00
Maximilian Bosch
de0a39166b
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
2021-04-16 13:18:25 +02:00
volth
bc0d605cf1 treewide: fix double quoted strings in meta.description
Signed-off-by: Ben Siraphob <bensiraphob@gmail.com>
2021-01-24 19:56:59 +07:00
rnhmjoj
9f52d1f234
Revert "nixos/wireless: fix failure with no interfaces"
This reverts commit 8f177612b1.

Attempting to start any service from udev when systemd-udev-settle is
used at all hangs the boot for 2min. See issue #107341.
2020-12-22 10:17:32 +01:00
rnhmjoj
8f177612b1
nixos/wireless: fix failure with no interfaces
This resolves issue #101963.

When the service is started and no interface is ready yet, wpa_supplicant
is being exec'd with no `-i` flags, thus failing. Once the interfaces
are ready, the udev rule would fire but wouldn't restart the unit because
it wasn't currently running (see systemctl(1) try-restart).

The solution is to exit (with a clear error message) but always restart
wpa_supplicant when the interfaces are modified.
2020-11-24 00:18:18 +01:00
Herwig Hochleitner
8e3da733b1 nixos: wpa_supplicant: warn on unused config 2020-08-25 12:29:58 +02:00
Bob Rubbens
71ea6a9a41 nixos/wpa_supplicant: update config generation
Ensure wpa_supplicant.conf is also generated when userControlled and
extraConfig are used. (As discussed in issue #59959)
2020-07-25 14:24:57 +02:00
Florian Klink
1955982190 nixos/wpa_supplicant: always run systemctl of the currently running systemd 2020-05-21 10:31:08 +02:00
Linus Heckemann
bbd6d219e4 nixos/wpa_supplicant: fix #61391 2020-01-12 14:14:16 +01:00
toonn
82fc9ab5c8 nixos/wpa_supplicant: fix unit-start script
Ever since setting up bonding the `wpa_supplicant-unit-start` script has
been failing. This is because the file `bonding_masters` in
`/sys/class/net/` is *not* a directory containing `uevent`.

Adding a test to verify the `uevent` path to be sourced exists resolves
the problem.
2019-11-12 17:53:29 +01:00
Craige McWhirter
cce7486deb nixos/doc: Clarify wireless examples
This commits makes it clearer to a novice reader how to configure several
diferent types of SSID connections that were otherwise obscurely documented

Resolves #66650
2019-09-26 22:52:21 -04:00
Svein Ove Aas
ac50d8e709 nixos/wpa_supplicant: Include CRDA regulatory database 2019-07-28 22:10:28 +01:00
Bob van der Linden
210b7134d3
nixos/wpa_supplicant: /var/run -> /run 2019-03-24 21:15:29 +01:00
Robert Helgesson
488a3f09cd
nixos/wpa_supplicant: use <citerefentry>
Fixes #55505
2019-02-10 13:23:28 +01:00
Maximilian Bosch
acbadcdbba
nixos/wpa_supplicant: escape interface names to listen on
Systemd provides some functionality to escape strings that are supposed
to be part of a unit name[1]. This seems to be used for interface names
in `sys-subsystem-net-devices-{interface}.device` and breaks
wpa_supplicant if the wireless interface name has a dash which is
encoded to \x2d.

Such an interface name is rather rare, but used i.e. when configuring
multiple wireless interfaces with `networking.wlanInterfaces`[2] to have on
interface for `wpa_supplicant` and another one for `hostapd`.

[1] https://www.freedesktop.org/software/systemd/man/systemd-escape.html
[2] https://nixos.org/nixos/options.html#networking.wlaninterfaces
2019-01-27 11:59:18 +01:00
Deven Lahoti
8d6128208d nixos/wireless: add extraConfig section to networking.wireless
This allows the user to add `wpa_supplicant` config options not yet supported by Nix without having to write the entire `wpa_supplicant.conf` file manually.
2018-08-09 15:20:44 -05:00
rnhmjoj
2918f6a3f0
nixos/wireless: add manual network configuration 2017-11-11 23:11:46 +01:00
Franz Pletz
725dee203a
wpa_supplicant service: restart instead of stop & start
We now wait for dhcpcd to acquire a lease but dhcpcd is restarted on
system activation. As wpa_supplicant is stopped while dhcpcd is
restarting a significant delay is introduced on systems with wireless
network connections only. This changes the wpa_supplicant service to
also be restarted together with dhcpcd in case both services were
changed.
2017-09-27 23:38:03 +02:00
Valentin Shirokov
e138d3afdf Added option networking.wireless.networks.*.priority
It is literal 'priority' option of wpa_supplicant.conf
2017-01-07 20:23:12 +08:00
Alexander Ried
57d9c69c6a supplicant: fix wants and wantedBy 2016-10-20 20:17:17 +02:00