From fe5fcf26c8e956680905ac4ea0a01b6e9cb0b5e6 Mon Sep 17 00:00:00 2001 From: DavHau Date: Mon, 26 May 2025 18:34:39 +0700 Subject: [PATCH] clanModules/wifi: remove module It was replaces by a service module and experimental anyways --- clanModules/wifi/README.md | 7 -- clanModules/wifi/default.nix | 5 -- clanModules/wifi/roles/default.nix | 110 ----------------------------- 3 files changed, 122 deletions(-) delete mode 100644 clanModules/wifi/README.md delete mode 100644 clanModules/wifi/default.nix delete mode 100644 clanModules/wifi/roles/default.nix diff --git a/clanModules/wifi/README.md b/clanModules/wifi/README.md deleted file mode 100644 index 63704215e..000000000 --- a/clanModules/wifi/README.md +++ /dev/null @@ -1,7 +0,0 @@ ---- -description = "Configures Wifi networks to join" -features = [ "inventory", "experimental", "deprecated" ] -categories = [ "Network", "System" ] ---- - -## Experimental wifi module diff --git a/clanModules/wifi/default.nix b/clanModules/wifi/default.nix deleted file mode 100644 index 0dead62d2..000000000 --- a/clanModules/wifi/default.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ - imports = [ - ./roles/default.nix - ]; -} diff --git a/clanModules/wifi/roles/default.nix b/clanModules/wifi/roles/default.nix deleted file mode 100644 index 976012941..000000000 --- a/clanModules/wifi/roles/default.nix +++ /dev/null @@ -1,110 +0,0 @@ -{ - lib, - config, - pkgs, - ... -}: - -let - cfg = config.clan.wifi; - - inherit (lib) - concatMapAttrsStringSep - flip - mapAttrs - ; - - password_path = - network_name: config.clan.core.vars.generators."iwd.${network_name}".files.password.path; - - ssid_path = network_name: config.clan.core.vars.generators."iwd.${network_name}".files.ssid.path; - - secret_generator = name: value: { - name = "iwd.${name}"; - value = { - prompts.ssid.type = "line"; - prompts.ssid.persist = true; - prompts.password.type = "hidden"; - prompts.password.persist = true; - share = true; - }; - }; -in -{ - options.clan.wifi = { - networks = lib.mkOption { - visible = false; - type = lib.types.attrsOf ( - lib.types.submodule ( - { ... }: - { - options = { - enable = lib.mkOption { - type = lib.types.bool; - default = true; - description = "Enable this 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"; - }; - }; - - config = lib.mkIf (cfg.networks != { }) { - - clan.core.vars.generators = lib.mapAttrs' secret_generator cfg.networks; - - networking.networkmanager.enable = true; - - networking.networkmanager.ensureProfiles.environmentFiles = [ - "/run/secrets/NetworkManager/wifi-secrets" - ]; - - networking.networkmanager.ensureProfiles.profiles = flip mapAttrs cfg.networks ( - name: _network: { - connection.id = "$ssid_${name}"; - connection.type = "wifi"; - wifi.mode = "infrastructure"; - wifi.ssid = "$ssid_${name}"; - wifi-security.psk = "$pw_${name}"; - wifi-security.key-mgmt = "wpa-psk"; - } - ); - - # service to generate the environment file containing all secrets, as - # expected by the nixos NetworkManager-ensure-profile service - systemd.services.NetworkManager-setup-secrets = { - description = "Generate wifi secrets for NetworkManager"; - requiredBy = [ "NetworkManager-ensure-profiles.service" ]; - partOf = [ "NetworkManager-ensure-profiles.service" ]; - before = [ "NetworkManager-ensure-profiles.service" ]; - serviceConfig = { - Type = "oneshot"; - ExecStart = pkgs.writeShellScript "wifi-secrets" '' - set -euo pipefail - - env_file=/run/secrets/NetworkManager/wifi-secrets - mkdir -p $(dirname "$env_file") - : > "$env_file" - - # Generate the secrets file - echo "Generating wifi secrets file: $env_file" - ${flip (concatMapAttrsStringSep "\n") cfg.networks ( - name: _network: '' - echo "ssid_${name}=\"$(cat "${ssid_path name}")\"" >> /run/secrets/NetworkManager/wifi-secrets - echo "pw_${name}=\"$(cat "${password_path name}")\"" >> /run/secrets/NetworkManager/wifi-secrets - '' - )} - ''; - }; - }; - }; -}