From a279c2b48f43570b3542174cd2e59627fc30ca76 Mon Sep 17 00:00:00 2001 From: DavHau Date: Tue, 3 Jun 2025 19:26:40 +0700 Subject: [PATCH] iwd: fix deprecation spam use config.warnings instead of lib.warn --- clanModules/iwd/README.md | 2 +- clanModules/iwd/roles/default.nix | 148 +++++++++++++++--------------- 2 files changed, 76 insertions(+), 74 deletions(-) diff --git a/clanModules/iwd/README.md b/clanModules/iwd/README.md index b1bbb622e..40855c5a4 100644 --- a/clanModules/iwd/README.md +++ b/clanModules/iwd/README.md @@ -1,6 +1,6 @@ --- description = "Automatically provisions wifi credentials" -features = [ "inventory" ] +features = [ "inventory", "deprecated" ] categories = [ "Network" ] --- diff --git a/clanModules/iwd/roles/default.nix b/clanModules/iwd/roles/default.nix index ae05c5608..e5bc7b5c8 100644 --- a/clanModules/iwd/roles/default.nix +++ b/clanModules/iwd/roles/default.nix @@ -33,80 +33,82 @@ let }; }; in -lib.warn - '' - The clan module `iwd` is deprecated and replaced by the clan service `wifi` - Please migrate your config to the new service (see: https://docs.clan.lol/reference/clanServices/wifi/) - - To keep passwords after migrating the config, use: - clan vars get iwd./ssid | clan vars set wifi./network-name - and: - clan vars get iwd./password | clan vars set wifi./password - '' - { - options.clan.iwd = { - networks = lib.mkOption { - type = lib.types.attrsOf ( - lib.types.submodule ( - { name, ... }: - { - options = { - ssid = lib.mkOption { - type = lib.types.str; - default = name; - description = "The name of the wifi network"; - }; - AutoConnect = lib.mkOption { - type = lib.types.bool; - default = true; - description = "Automatically try to join this wifi network"; - }; +{ + options.clan.iwd = { + networks = lib.mkOption { + type = lib.types.attrsOf ( + lib.types.submodule ( + { name, ... }: + { + options = { + ssid = lib.mkOption { + type = lib.types.str; + default = name; + description = "The name of the wifi network"; + }; + AutoConnect = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Automatically try to join this wifi network"; }; - } - ) - ); - default = { }; - description = "Wifi networks to predefine"; - }; - }; - - imports = [ - (lib.mkRemovedOptionModule [ - "clan" - "iwd" - "enable" - ] "Just define clan.iwd.networks to enable it") - ]; - - config = lib.mkMerge [ - (lib.mkIf (cfg.networks != { }) { - # Systemd tmpfiles rule to create /var/lib/iwd/example.psk file - systemd.tmpfiles.rules = lib.mapAttrsToList ( - _: value: "C /var/lib/iwd/${value.ssid}.psk 0600 root root - ${secret_path value.ssid}" - ) cfg.networks; - - clan.core.vars.generators = lib.mapAttrs' secret_generator cfg.networks; - - # TODO: restart the iwd.service if something changes - }) - { - # disable wpa supplicant - networking.wireless.enable = false; - - # Set the network manager backend to iwd - networking.networkmanager.wifi.backend = "iwd"; - - # Use iwd instead of wpa_supplicant. It has a user friendly CLI - networking.wireless.iwd = { - enable = true; - settings = { - Network = { - EnableIPv6 = true; - RoutePriorityOffset = 300; }; - Settings.AutoConnect = true; + } + ) + ); + default = { }; + description = "Wifi networks to predefine"; + }; + }; + + imports = [ + (lib.mkRemovedOptionModule [ + "clan" + "iwd" + "enable" + ] "Just define clan.iwd.networks to enable it") + ]; + + config = lib.mkMerge [ + (lib.mkIf (cfg.networks != { }) { + # Systemd tmpfiles rule to create /var/lib/iwd/example.psk file + systemd.tmpfiles.rules = lib.mapAttrsToList ( + _: value: "C /var/lib/iwd/${value.ssid}.psk 0600 root root - ${secret_path value.ssid}" + ) cfg.networks; + + clan.core.vars.generators = lib.mapAttrs' secret_generator cfg.networks; + + # TODO: restart the iwd.service if something changes + }) + { + warnings = [ + '' + The clan module `iwd` is deprecated and replaced by the clan service `wifi` + Please migrate your config to the new service (see: https://docs.clan.lol/reference/clanServices/wifi/) + + To keep passwords after migrating the config, use: + clan vars get iwd./ssid | clan vars set wifi./network-name + and: + clan vars get iwd./password | clan vars set wifi./password + '' + ]; + + # disable wpa supplicant + networking.wireless.enable = false; + + # Set the network manager backend to iwd + networking.networkmanager.wifi.backend = "iwd"; + + # Use iwd instead of wpa_supplicant. It has a user friendly CLI + networking.wireless.iwd = { + enable = true; + settings = { + Network = { + EnableIPv6 = true; + RoutePriorityOffset = 300; }; + Settings.AutoConnect = true; }; - } - ]; - } + }; + } + ]; +}