From 688d658a9689194787f6df15b83daad7e78f20bc Mon Sep 17 00:00:00 2001 From: rnhmjoj Date: Wed, 25 Jan 2023 10:19:20 +0100 Subject: [PATCH] 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. --- .../modules/services/networking/wpa_supplicant.nix | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/networking/wpa_supplicant.nix b/nixos/modules/services/networking/wpa_supplicant.nix index 119575bdddb4..0595e9e6df23 100644 --- a/nixos/modules/services/networking/wpa_supplicant.nix +++ b/nixos/modules/services/networking/wpa_supplicant.nix @@ -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}"