1 { config, lib, pkgs, ... }:
5 mkEnableOption mkPackageOption 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 "iwd";
22 package = mkPackageOption pkgs "iwd" { };
29 Settings.AutoConnect = true;
33 RoutePriorityOffset = 300;
38 Options passed to iwd.
39 See [here](https://iwd.wiki.kernel.org/networkconfigurationsettings) for supported options.
44 config = mkIf cfg.enable {
46 assertion = !config.networking.wireless.enable;
48 Only one wireless daemon is allowed at the time: networking.wireless.enable and networking.wireless.iwd.enable are mutually exclusive.
52 environment.etc."iwd/${configFile.name}".source = configFile;
55 environment.systemPackages = [ cfg.package ];
57 services.dbus.packages = [ cfg.package ];
59 systemd.packages = [ cfg.package ];
61 systemd.network.links."80-iwd" = {
62 matchConfig.Type = "wlan";
63 linkConfig.NamePolicy = "keep kernel";
66 systemd.services.iwd = {
67 path = [ config.networking.resolvconf.package ];
68 wantedBy = [ "multi-user.target" ];
69 restartTriggers = [ configFile ];
70 serviceConfig.ReadWritePaths = "-/etc/resolv.conf";
74 meta.maintainers = with lib.maintainers; [ dtzWill ];