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.
This commit is contained in:
rnhmjoj 2023-01-25 10:19:20 +01:00
parent 6fe6edbd8a
commit 688d658a96
No known key found for this signature in database
GPG Key ID: BFBAF4C975F76450

View File

@ -121,11 +121,15 @@ let
''}
# 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}"