Merge pull request 'iwd: fix deprecation spam' (#3832) from DavHau-dave into main

Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3832
This commit is contained in:
hsjobeki
2025-06-03 16:47:27 +00:00
3 changed files with 77 additions and 75 deletions

View File

@@ -1,6 +1,6 @@
--- ---
description = "Automatically provisions wifi credentials" description = "Automatically provisions wifi credentials"
features = [ "inventory" ] features = [ "inventory", "deprecated" ]
categories = [ "Network" ] categories = [ "Network" ]
--- ---

View File

@@ -33,80 +33,82 @@ let
}; };
}; };
in in
lib.warn {
'' options.clan.iwd = {
The clan module `iwd` is deprecated and replaced by the clan service `wifi` networks = lib.mkOption {
Please migrate your config to the new service (see: https://docs.clan.lol/reference/clanServices/wifi/) type = lib.types.attrsOf (
lib.types.submodule (
To keep passwords after migrating the config, use: { name, ... }:
clan vars get <your-machine> iwd.<network-name>/ssid | clan vars set <your-machine> wifi.<network-name>/network-name {
and: options = {
clan vars get <your-machine> iwd.<network-name>/password | clan vars set <your-machine> wifi.<network-name>/password ssid = lib.mkOption {
'' type = lib.types.str;
{ default = name;
options.clan.iwd = { description = "The name of the wifi network";
networks = lib.mkOption { };
type = lib.types.attrsOf ( AutoConnect = lib.mkOption {
lib.types.submodule ( type = lib.types.bool;
{ name, ... }: default = true;
{ description = "Automatically try to join this wifi network";
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 <your-machine> iwd.<network-name>/ssid | clan vars set <your-machine> wifi.<network-name>/network-name
and:
clan vars get <your-machine> iwd.<network-name>/password | clan vars set <your-machine> wifi.<network-name>/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;
}; };
} };
]; }
} ];
}

View File

@@ -579,7 +579,7 @@ def produce_clan_modules_docs() -> None:
!!! Warning "Deprecated" !!! Warning "Deprecated"
The `{module_name}` module is deprecated.* The `{module_name}` module is deprecated.*
Use [clanServices/{module_name}](../clanServices/{module_name}.md) instead Use 'clanServices/{module_name}' or a similar successor instead
""" """
else: else:
output += f""" output += f"""