nixos/iwd: add settings option

This commit is contained in:
fortuneteller2k 2021-05-20 07:59:34 +08:00
parent 8dfc51d9c3
commit 6ea6734f71
3 changed files with 41 additions and 2 deletions

View file

@ -688,6 +688,15 @@
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>
The
<link xlink:href="options.html#opt-networking.wireless.iwd.enable">networking.wireless.iwd</link>
module has a new
<link xlink:href="options.html#opt-networking.wireless.iwd.settings">networking.wireless.iwd.settings</link>
option.
</para>
</listitem>
</itemizedlist>
</section>
</section>

View file

@ -179,3 +179,5 @@ pt-services.clipcat.enable).
- NSS modules which should be queried after `resolved`, `files` and
`myhostname`, but before `dns` should use the default priority
- NSS modules which should come after `dns` should use mkAfter.
- The [networking.wireless.iwd](options.html#opt-networking.wireless.iwd.enable) module has a new [networking.wireless.iwd.settings](options.html#opt-networking.wireless.iwd.settings) option.

View file

@ -4,8 +4,31 @@ with lib;
let
cfg = config.networking.wireless.iwd;
ini = pkgs.formats.ini { };
configFile = ini.generate "main.conf" cfg.settings;
in {
options.networking.wireless.iwd.enable = mkEnableOption "iwd";
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.
'';
};
};
config = mkIf cfg.enable {
assertions = [{
@ -15,6 +38,8 @@ in {
'';
}];
environment.etc."iwd/main.conf".source = configFile;
# for iwctl
environment.systemPackages = [ pkgs.iwd ];
@ -27,7 +52,10 @@ in {
linkConfig.NamePolicy = "keep kernel";
};
systemd.services.iwd.wantedBy = [ "multi-user.target" ];
systemd.services.iwd = {
wantedBy = [ "multi-user.target" ];
restartTriggers = [ configFile ];
};
};
meta.maintainers = with lib.maintainers; [ mic92 dtzWill ];