From 914d50a1c575e01cb95e688da1746d20c2998535 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Mon, 15 Jul 2024 19:14:23 +0200 Subject: [PATCH] Inventory: only apply if settings.json exists --- lib/build-clan/default.nix | 25 ++++++++++++++++--------- templates/flake-parts/flake.nix | 1 - 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/build-clan/default.nix b/lib/build-clan/default.nix index 2fe3fed26..35401dd1c 100644 --- a/lib/build-clan/default.nix +++ b/lib/build-clan/default.nix @@ -78,15 +78,22 @@ let # Will be deprecated { - machines = lib.mapAttrs ( - name: _: - # Use mkForce to make sure users migrate to the inventory system. - # When the settings.json exists the evaluation will print the deprecation warning. - lib.mkForce { - inherit name; - system = (machineSettings name).nixpkgs.hostSystem or null; - } - ) machinesDirs; + machines = + lib.mapAttrs + ( + name: _: + # Use mkForce to make sure users migrate to the inventory system. + # When the settings.json exists the evaluation will print the deprecation warning. + lib.mkForce { + inherit name; + system = (machineSettings name).nixpkgs.hostSystem or null; + } + ) + ( + lib.filterAttrs ( + machineName: _: builtins.pathExists "${directory}/machines/${machineName}/settings.json" + ) machinesDirs + ); } # Deprecated interface diff --git a/templates/flake-parts/flake.nix b/templates/flake-parts/flake.nix index 47b3e1f9f..b093b1766 100644 --- a/templates/flake-parts/flake.nix +++ b/templates/flake-parts/flake.nix @@ -99,7 +99,6 @@ */ # clan.core.networking.zerotier.networkId = builtins.readFile ../jon/facts/zerotier-network-id; }; - }; }; perSystem =