{ config, lib, vars, ... }: { # Prestages a NetworkManager connection profile for vars.wifiSsid so the # host associates on first boot with no manual nmtui/nmcli step. Guarded # on a non-empty SSID so leaving the placeholder blank in variables.nix # is a no-op rather than an empty, broken profile — fill it in once the # network is known. # # The password itself lives in secrets/gui.yaml, not variables.nix -- # NetworkManager's ensureProfiles renders `psk = "$WIFI_PASSWORD"` # literally into the store (see nixpkgs' own ensureProfiles example, # which does the same for exactly this reason) and its systemd service # envsubst-expands it from environmentFiles at activation time, so the # real value only ever touches /run (root-only, UMask 0177), never the # Nix store. sops.secrets."wifi-password" = lib.mkIf (vars.wifiSsid != "") { sopsFile = ../../secrets/gui.yaml; }; sops.templates."wifi-password.env" = lib.mkIf (vars.wifiSsid != "") { content = "WIFI_PASSWORD=${config.sops.placeholder."wifi-password"}"; }; networking.networkmanager.ensureProfiles = lib.mkIf (vars.wifiSsid != "") { environmentFiles = [ config.sops.templates."wifi-password.env".path ]; profiles.${vars.wifiSsid} = { connection = { id = vars.wifiSsid; type = "wifi"; }; wifi = { mode = "infrastructure"; ssid = vars.wifiSsid; }; wifi-security = { key-mgmt = "wpa-psk"; psk = "$WIFI_PASSWORD"; }; }; }; }