1 { config, lib, pkgs, ... }:
5 mkEnableOption mkIf mkOption types
8 cfg = config.networking.wireless.iwd;
9 ini = pkgs.formats.ini { };
11 # without UseDefaultInterface, sometimes wlan0 simply goes AWOL with NetworkManager
12 # https://iwd.wiki.kernel.org/interface_lifecycle#interface_management_in_iwd
13 General.UseDefaultInterface = with config.networking.networkmanager; (enable && (wifi.backend == "iwd"));
15 configFile = ini.generate "main.conf" (recursiveUpdate defaults cfg.settings);
19 options.networking.wireless.iwd = {
20 enable = mkEnableOption (lib.mdDoc "iwd");
25 defaultText = lib.literalExpression "pkgs.iwd";
26 description = lib.mdDoc ''
27 The iwd package to use.
36 Settings.AutoConnect = true;
40 RoutePriorityOffset = 300;
44 description = lib.mdDoc ''
45 Options passed to iwd.
46 See [here](https://iwd.wiki.kernel.org/networkconfigurationsettings) for supported options.
51 config = mkIf cfg.enable {
53 assertion = !config.networking.wireless.enable;
55 Only one wireless daemon is allowed at the time: networking.wireless.enable and networking.wireless.iwd.enable are mutually exclusive.
59 environment.etc."iwd/${configFile.name}".source = configFile;
62 environment.systemPackages = [ cfg.package ];
64 services.dbus.packages = [ cfg.package ];
66 systemd.packages = [ cfg.package ];
68 systemd.network.links."80-iwd" = {
69 matchConfig.Type = "wlan";
70 linkConfig.NamePolicy = "keep kernel";
73 systemd.services.iwd = {
74 wantedBy = [ "multi-user.target" ];
75 restartTriggers = [ configFile ];
79 meta.maintainers = with lib.maintainers; [ dtzWill ];