2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.networking.wireless.iwd;
|
2021-08-05 21:33:18 +00:00
|
|
|
ini = pkgs.formats.ini { };
|
|
|
|
configFile = ini.generate "main.conf" cfg.settings;
|
2020-04-24 23:36:52 +00:00
|
|
|
in {
|
2021-08-05 21:33:18 +00:00
|
|
|
options.networking.wireless.iwd = {
|
|
|
|
enable = mkEnableOption "iwd";
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = ini.type;
|
|
|
|
default = { };
|
|
|
|
|
|
|
|
example = {
|
|
|
|
Settings.AutoConnect = true;
|
|
|
|
|
|
|
|
Network = {
|
|
|
|
EnableIPv6 = true;
|
|
|
|
RoutePriorityOffset = 300;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
description = ''
|
|
|
|
Options passed to iwd.
|
|
|
|
See <link xlink:href="https://iwd.wiki.kernel.org/networkconfigurationsettings">here</link> for supported options.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-04-24 23:36:52 +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.
|
|
|
|
'';
|
|
|
|
}];
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
environment.etc."iwd/main.conf".source = configFile;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
# for iwctl
|
|
|
|
environment.systemPackages = [ pkgs.iwd ];
|
|
|
|
|
|
|
|
services.dbus.packages = [ pkgs.iwd ];
|
|
|
|
|
|
|
|
systemd.packages = [ pkgs.iwd ];
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
systemd.network.links."80-iwd" = {
|
|
|
|
matchConfig.Type = "wlan";
|
|
|
|
linkConfig.NamePolicy = "keep kernel";
|
|
|
|
};
|
|
|
|
|
2021-08-05 21:33:18 +00:00
|
|
|
systemd.services.iwd = {
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
restartTriggers = [ configFile ];
|
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ mic92 dtzWill ];
|
|
|
|
}
|