From 4c6b6489a41339809e4dc73086db16425cad6466 Mon Sep 17 00:00:00 2001 From: oddlama Date: Sat, 13 Sep 2025 23:27:33 +0200 Subject: [PATCH] fix: don't fail if id file is not set --- modules/wireguard.nix | 2 +- modules/wireguardGlobals.nix | 13 +++---------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/modules/wireguard.nix b/modules/wireguard.nix index 59bd5ab..eedbdf3 100644 --- a/modules/wireguard.nix +++ b/modules/wireguard.nix @@ -36,7 +36,7 @@ in flip mapAttrsToList memberWG ( networkName: networkCfg: let - assertionPrefix = "While evaluation the wireguard network ${networkName}:"; + assertionPrefix = "While evaluating the wireguard network ${networkName}:"; hostCfg = networkCfg.hosts.${config.node.name}; in [ diff --git a/modules/wireguardGlobals.nix b/modules/wireguardGlobals.nix index d2d83d3..1626cc2 100644 --- a/modules/wireguardGlobals.nix +++ b/modules/wireguardGlobals.nix @@ -23,7 +23,7 @@ in options = { host = mkOption { type = types.str; - description = "The host name or IP addresse for reaching the server node."; + description = "The host name or IP address under which the server node is reachable from any client."; }; idFile = mkOption { type = types.nullOr types.path; @@ -61,16 +61,9 @@ in config.id = let inherit (wgConf) idFile; + idFromFile = if (idFile == null) then null else (importJSON idFile).${name} or null; in - if (idFile == null) then - null - else - ( - let - conf = importJSON idFile; - in - conf.${name} or null - ); + lib.mkIf (idFromFile != null) idFromFile; options = { server = mkOption { default = false;