From 39b34d9ff3ba90ac1fc4397f041961fcced10bba Mon Sep 17 00:00:00 2001 From: a-kenji Date: Tue, 21 May 2024 17:23:49 +0200 Subject: [PATCH] modules: static hosts filter nonexistent ip --- clanModules/static-hosts/default.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/clanModules/static-hosts/default.nix b/clanModules/static-hosts/default.nix index 6cc5f106..028dda87 100644 --- a/clanModules/static-hosts/default.nix +++ b/clanModules/static-hosts/default.nix @@ -18,7 +18,13 @@ name: _: !(lib.elem name config.clan.static-hosts.excludeHosts) ) machines; in - (lib.mapAttrs' ( - machine: _: lib.nameValuePair (builtins.readFile (zerotierIpMachinePath machine)) [ machine ] - ) filteredMachines); + lib.filterAttrs (_: value: value != null) ( + lib.mapAttrs' ( + machine: _: + let + path = zerotierIpMachinePath machine; + in + if builtins.pathExists path then lib.nameValuePair (builtins.readFile path) [ machine ] else null + ) filteredMachines + ); }