nixpkgs/nixos/modules/services/networking/iwd.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

76 lines
2.0 KiB
Nix
Raw Normal View History

2017-04-23 21:12:21 +00:00
{ config, lib, pkgs, ... }:
let
inherit (lib)
mkEnableOption mkPackageOption mkIf mkOption types
recursiveUpdate;
2017-04-23 21:12:21 +00:00
cfg = config.networking.wireless.iwd;
2021-05-19 23:59:34 +00:00
ini = pkgs.formats.ini { };
defaults = {
# without UseDefaultInterface, sometimes wlan0 simply goes AWOL with NetworkManager
# https://iwd.wiki.kernel.org/interface_lifecycle#interface_management_in_iwd
General.UseDefaultInterface = with config.networking.networkmanager; (enable && (wifi.backend == "iwd"));
};
configFile = ini.generate "main.conf" (recursiveUpdate defaults cfg.settings);
in
{
2021-05-19 23:59:34 +00:00
options.networking.wireless.iwd = {
enable = mkEnableOption (lib.mdDoc "iwd");
package = mkPackageOption pkgs "iwd" { };
2022-10-16 11:38:33 +00:00
2021-05-19 23:59:34 +00:00
settings = mkOption {
type = ini.type;
default = { };
example = {
Settings.AutoConnect = true;
Network = {
EnableIPv6 = true;
RoutePriorityOffset = 300;
};
};
description = lib.mdDoc ''
Options passed to iwd.
See [here](https://iwd.wiki.kernel.org/networkconfigurationsettings) for supported options.
'';
};
};
2017-04-23 21:12:21 +00:00
config = mkIf cfg.enable {
assertions = [{
assertion = !config.networking.wireless.enable;
message = ''
Only one wireless daemon is allowed at the time: networking.wireless.enable and networking.wireless.iwd.enable are mutually exclusive.
'';
}];
environment.etc."iwd/${configFile.name}".source = configFile;
2021-05-19 23:59:34 +00:00
2017-04-23 21:12:21 +00:00
# for iwctl
2022-10-16 11:38:33 +00:00
environment.systemPackages = [ cfg.package ];
2017-04-23 21:12:21 +00:00
2022-10-16 11:38:33 +00:00
services.dbus.packages = [ cfg.package ];
2017-04-23 21:12:21 +00:00
2022-10-16 11:38:33 +00:00
systemd.packages = [ cfg.package ];
2018-07-01 09:58:19 +00:00
systemd.network.links."80-iwd" = {
matchConfig.Type = "wlan";
linkConfig.NamePolicy = "keep kernel";
};
2021-05-19 23:59:34 +00:00
systemd.services.iwd = {
path = [ config.networking.resolvconf.package ];
2021-05-19 23:59:34 +00:00
wantedBy = [ "multi-user.target" ];
restartTriggers = [ configFile ];
serviceConfig.ReadWritePaths = "-/etc/resolv.conf";
2021-05-19 23:59:34 +00:00
};
2017-04-23 21:12:21 +00:00
};
2022-10-08 14:50:33 +00:00
meta.maintainers = with lib.maintainers; [ dtzWill ];
2017-04-23 21:12:21 +00:00
}