nixos/wireless: fix failure on missing config file

This change prevents doing the secret substitution when the config is
missing, which would result in an error.

The service can be useful even without configuration; for example
connman controls wpa_supplicant using dbus and as such it does not need
a config file nor any other declarative options.

rnhmjoj 688d658a 6fe6edbd

Changed files
+9 -5
nixos
modules
services
networking
+9 -5
nixos/modules/services/networking/wpa_supplicant.nix
···
''}
# substitute environment variables
-
${pkgs.gawk}/bin/awk '{
-
for(varname in ENVIRON)
-
gsub("@"varname"@", ENVIRON[varname])
-
print
-
}' "${configFile}" > "${finalConfig}"
+
if [ -f "${configFile}" ]; then
+
${pkgs.gawk}/bin/awk '{
+
for(varname in ENVIRON)
+
gsub("@"varname"@", ENVIRON[varname])
+
print
+
}' "${configFile}" > "${finalConfig}"
+
else
+
touch "${finalConfig}"
+
fi
iface_args="-s ${optionalString cfg.dbusControlled "-u"} -D${cfg.driver} ${configStr}"