From 667cee0f6e5632934ed14a524aec70d231330622 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Tue, 1 Jul 2025 11:56:31 +0200 Subject: [PATCH] buildClan: replace all usages by lib.clan --- .../service-dummy-test-from-flake/flake.nix | 4 +- clanServices/hello-world/tests/eval-tests.nix | 4 +- clanServices/wifi/tests/eval-tests.nix | 4 +- clanServices/zerotier/tests/eval-tests.nix | 49 ++++++++++--------- lib/modules/flake-module.nix | 2 - lib/modules/tests.nix | 1 - .../tests/test_flake_with_core/flake.nix | 4 +- .../test_flake_with_core_and_pass/flake.nix | 4 +- .../flake.nix | 4 +- templates/clan/minimal/flake.nix | 4 +- templates/clan/new-clan/flake.nix | 4 +- 11 files changed, 41 insertions(+), 43 deletions(-) diff --git a/checks/service-dummy-test-from-flake/flake.nix b/checks/service-dummy-test-from-flake/flake.nix index d3c7ee75f..15294917b 100644 --- a/checks/service-dummy-test-from-flake/flake.nix +++ b/checks/service-dummy-test-from-flake/flake.nix @@ -6,7 +6,7 @@ { self, clan-core, ... }: let # Usage see: https://docs.clan.lol - clan = clan-core.clanLib.buildClan { + clan = clan-core.lib.clan { inherit self; inventory = @@ -66,6 +66,6 @@ in { # all machines managed by Clan - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; }; } diff --git a/clanServices/hello-world/tests/eval-tests.nix b/clanServices/hello-world/tests/eval-tests.nix index 4f11977f5..5194ff4e0 100644 --- a/clanServices/hello-world/tests/eval-tests.nix +++ b/clanServices/hello-world/tests/eval-tests.nix @@ -4,7 +4,7 @@ ... }: let - testFlake = clanLib.buildClan { + testFlake = clanLib.clan { # Point to the folder of the module # TODO: make this optional directory = ./..; @@ -43,7 +43,7 @@ let in { test_simple = { - inherit testFlake; + config = testFlake.config; expr = { }; expected = { }; diff --git a/clanServices/wifi/tests/eval-tests.nix b/clanServices/wifi/tests/eval-tests.nix index b2f4c329f..b4d33c6f8 100644 --- a/clanServices/wifi/tests/eval-tests.nix +++ b/clanServices/wifi/tests/eval-tests.nix @@ -4,7 +4,7 @@ ... }: let - testFlake = clanLib.buildClan { + testFlake = clanLib.clan { # Point to the folder of the module # TODO: make this optional directory = ./..; @@ -47,7 +47,7 @@ in inherit testFlake; expr = - testFlake.clan.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config; + testFlake.config.clan.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config; expected = 1; # expr = { diff --git a/clanServices/zerotier/tests/eval-tests.nix b/clanServices/zerotier/tests/eval-tests.nix index 849d2e007..3f57eafa7 100644 --- a/clanServices/zerotier/tests/eval-tests.nix +++ b/clanServices/zerotier/tests/eval-tests.nix @@ -4,32 +4,33 @@ ... }: let - testFlake = clanLib.buildClan { - directory = ./vm; + testFlake = + (clanLib.clan { + directory = ./vm; - machines.jon = { - nixpkgs.hostPlatform = "x86_64-linux"; - }; - machines.sara = { - nixpkgs.hostPlatform = "x86_64-linux"; - }; - machines.bam = { - nixpkgs.hostPlatform = "x86_64-linux"; - }; - - modules.zerotier = module; - - inventory.instances = { - zerotier = { - module.name = "zerotier"; - module.input = "self"; - - roles.peer.tags.all = { }; - roles.moon.machines.sara.settings.stableEndpoints = [ "10.0.0.3/9993" ]; - roles.controller.machines.bam = { }; + machines.jon = { + nixpkgs.hostPlatform = "x86_64-linux"; }; - }; - }; + machines.sara = { + nixpkgs.hostPlatform = "x86_64-linux"; + }; + machines.bam = { + nixpkgs.hostPlatform = "x86_64-linux"; + }; + + modules.zerotier = module; + + inventory.instances = { + zerotier = { + module.name = "zerotier"; + module.input = "self"; + + roles.peer.tags.all = { }; + roles.moon.machines.sara.settings.stableEndpoints = [ "10.0.0.3/9993" ]; + roles.controller.machines.bam = { }; + }; + }; + }).config; in { test_peers = { diff --git a/lib/modules/flake-module.nix b/lib/modules/flake-module.nix index 27fe36909..815d7351b 100644 --- a/lib/modules/flake-module.nix +++ b/lib/modules/flake-module.nix @@ -31,9 +31,7 @@ in # Run: nix-unit --extra-experimental-features flakes --flake .#legacyPackages.x86_64-linux.evalTests-build-clan legacyPackages.evalTests-build-clan = import ./tests.nix { inherit lib; - inherit (inputs) nixpkgs; clan-core = self; - buildClan = self.clanLib.buildClan; }; checks = { eval-lib-build-clan = pkgs.runCommand "tests" { nativeBuildInputs = [ pkgs.nix-unit ]; } '' diff --git a/lib/modules/tests.nix b/lib/modules/tests.nix index fc5f23700..7e33f5805 100644 --- a/lib/modules/tests.nix +++ b/lib/modules/tests.nix @@ -1,7 +1,6 @@ { lib, clan-core, - ... }: let # Shallowly force all attribute values to be evaluated. diff --git a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core/flake.nix b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core/flake.nix index f09d2d200..d40700310 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core/flake.nix +++ b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core/flake.nix @@ -19,7 +19,7 @@ builtins.fromJSON (builtins.readFile ./clan_attrs.json) else { }; - clan = clan-core.clanLib.buildClan { + clan = clan-core.lib.clan { inherit self; meta.name = "test_flake_with_core"; # Don't quote this will be replaced by the inventory expression @@ -62,6 +62,6 @@ in { clan = clan_attrs_json; - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; }; } diff --git a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_and_pass/flake.nix b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_and_pass/flake.nix index 463bf4cf9..87832979d 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_and_pass/flake.nix +++ b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_and_pass/flake.nix @@ -8,7 +8,7 @@ outputs = { self, clan-core }: let - clan = clan-core.clanLib.buildClan { + clan = clan-core.lib.clan { inherit self; meta.name = "test_flake_with_core_and_pass"; machines = { @@ -44,6 +44,6 @@ }; in { - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; }; } diff --git a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_dynamic_machines/flake.nix b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_dynamic_machines/flake.nix index e6b4fb02a..730b3f81b 100644 --- a/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_dynamic_machines/flake.nix +++ b/pkgs/clan-cli/clan_cli/tests/test_flake_with_core_dynamic_machines/flake.nix @@ -8,7 +8,7 @@ outputs = { self, clan-core }: let - clan = clan-core.clanLib.buildClan { + clan = clan-core.lib.clan { inherit self; meta.name = "test_flake_with_core_dynamic_machines"; machines = @@ -19,6 +19,6 @@ }; in { - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; }; } diff --git a/templates/clan/minimal/flake.nix b/templates/clan/minimal/flake.nix index bc7e4b895..5beb5f5b1 100644 --- a/templates/clan/minimal/flake.nix +++ b/templates/clan/minimal/flake.nix @@ -6,10 +6,10 @@ { self, clan-core, ... }: let # Usage see: https://docs.clan.lol - clan = clan-core.clanLib.buildClan { inherit self; }; + clan = clan-core.lib.clan { inherit self; }; in { # all machines managed by Clan - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; }; } diff --git a/templates/clan/new-clan/flake.nix b/templates/clan/new-clan/flake.nix index 846a81081..141177063 100644 --- a/templates/clan/new-clan/flake.nix +++ b/templates/clan/new-clan/flake.nix @@ -6,7 +6,7 @@ { self, clan-core, ... }: let # Usage see: https://docs.clan.lol - clan = clan-core.clanLib.buildClan { + clan = clan-core.lib.clan { inherit self; # Ensure this is unique among all clans you want to use. meta.name = "__CHANGE_ME__"; @@ -26,7 +26,7 @@ }; in { - inherit (clan) nixosConfigurations nixosModules clanInternals; + inherit (clan.config) nixosConfigurations nixosModules clanInternals; # Add the Clan cli tool to the dev shell. # Use "nix develop" to enter the dev shell. devShells =