From d8d49c9d7275fb00d35a8885f130e303e3b16328 Mon Sep 17 00:00:00 2001 From: Johannes Kirschbauer Date: Thu, 26 Jun 2025 16:12:35 +0200 Subject: [PATCH] chore: clean up logic around clanInternals --- checks/backups/flake-module.nix | 4 +- checks/installation/flake-module.nix | 6 +-- clanServices/wifi/tests/eval-tests.nix | 2 +- flakeModules/clan.nix | 5 +-- lib/modules/public.nix | 21 ---------- lib/modules/tests.nix | 54 ++++++++++++-------------- 6 files changed, 32 insertions(+), 60 deletions(-) delete mode 100644 lib/modules/public.nix diff --git a/checks/backups/flake-module.nix b/checks/backups/flake-module.nix index ea1a65d39..452a07e6f 100644 --- a/checks/backups/flake-module.nix +++ b/checks/backups/flake-module.nix @@ -22,7 +22,7 @@ dependencies = [ self pkgs.stdenv.drvPath - self.clanInternals.machines.${pkgs.hostPlatform.system}.test-backup.config.system.clan.deployment.file + self.clan.clanInternals.machines.${pkgs.hostPlatform.system}.test-backup.config.system.clan.deployment.file ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs); closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; in @@ -162,7 +162,7 @@ ] ++ # import the inventory generated nixosModules - self.clanInternals.inventoryClass.machines.test-backup.machineImports; + self.clan.clanInternals.inventoryClass.machines.test-backup.machineImports; clan.core.settings.directory = ./.; }; diff --git a/checks/installation/flake-module.nix b/checks/installation/flake-module.nix index 07f565218..1fc5288f7 100644 --- a/checks/installation/flake-module.nix +++ b/checks/installation/flake-module.nix @@ -8,9 +8,9 @@ let { modulesPath, pkgs, ... }: let dependencies = [ - self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.build.toplevel - self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.build.diskoScript - self.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.clan.deployment.file + self.clan.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.build.toplevel + self.clan.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.build.diskoScript + self.clan.clanInternals.machines.${pkgs.hostPlatform.system}.test-install-machine-with-system.config.system.clan.deployment.file pkgs.stdenv.drvPath pkgs.bash.drvPath pkgs.nixos-anywhere diff --git a/clanServices/wifi/tests/eval-tests.nix b/clanServices/wifi/tests/eval-tests.nix index fa50c589f..9a53340d7 100644 --- a/clanServices/wifi/tests/eval-tests.nix +++ b/clanServices/wifi/tests/eval-tests.nix @@ -46,7 +46,7 @@ in inherit testFlake; expr = - testFlake.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config; + testFlake.clan.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config; expected = 1; # expr = { diff --git a/flakeModules/clan.nix b/flakeModules/clan.nix index fd9d59d98..fcf97993f 100644 --- a/flakeModules/clan.nix +++ b/flakeModules/clan.nix @@ -22,11 +22,8 @@ in options.flake = { # Backwards compat clanInternals = lib.mkOption { - description = "Internals as used by the clan cli. Deprecated use clan.clanInternals"; - visible = false; - readOnly = true; + description = "Internals as needed by the clan cli."; default = config.flake.clan.clanInternals; - apply = lib.warn "Use clan.clanInternals instead"; }; # The one and only clan module clan = lib.mkOption { diff --git a/lib/modules/public.nix b/lib/modules/public.nix deleted file mode 100644 index 73e7978e4..000000000 --- a/lib/modules/public.nix +++ /dev/null @@ -1,21 +0,0 @@ -/** - Publicly exported attribute names - These are mapped from 'options.clan.{name}' into 'flake.{name}' - For example "clanInternals" will be exposed as "flake.clan.clanInternals" - This list is used to guarantee equivalent attribute sets for both flake-parts and buildClan users. -*/ -{ - # flake.clan.{name} <- clan.{name} - clan = [ - "templates" - "modules" - ]; - # flake.{name} <- clan.{name} - topLevel = [ - "clanInternals" - "nixosConfigurations" - "nixosModules" - "darwinConfigurations" - "darwinModules" - ]; -} diff --git a/lib/modules/tests.nix b/lib/modules/tests.nix index c9d8f1be0..d8991e510 100644 --- a/lib/modules/tests.nix +++ b/lib/modules/tests.nix @@ -15,20 +15,19 @@ in { test_missing_self = let - clan = buildClan { + eval = buildClan { meta.name = "test"; directory = ./.; }; in { - inherit clan; - expr = shallowForceAllAttributes clan; + expr = shallowForceAllAttributes eval.config; expected = true; }; test_only_required = let - clan = buildClan { + eval = buildClan { self = { inputs = { }; outPath = ./.; @@ -37,13 +36,13 @@ in }; in { - expr = shallowForceAllAttributes clan; + expr = shallowForceAllAttributes eval.config; expected = true; }; test_all_simple = let - config = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -55,13 +54,13 @@ in }; in { - expr = config ? inventory; + expr = eval.config ? inventory; expected = true; }; test_outputs_clanInternals = let - config = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -72,15 +71,12 @@ in directory = ./.; inventory.meta.name = "test"; } - - ./clan/module.nix - # Explicit output, usually defined by flake-parts - { options.nixosConfigurations = lib.mkOption { type = lib.types.raw; }; } ]; }; in { - expr = config.clanInternals.inventory.meta; + inherit eval; + expr = eval.config.clanInternals.inventory.meta; expected = { description = null; icon = null; @@ -90,7 +86,7 @@ in test_fn_simple = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -99,13 +95,13 @@ in }; in { - expr = lib.isAttrs result.clanInternals; + expr = lib.isAttrs eval.config.clanInternals; expected = true; }; test_fn_clan_core = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -114,7 +110,7 @@ in }; in { - expr = builtins.attrNames result.nixosConfigurations; + expr = builtins.attrNames eval.config.nixosConfigurations; expected = [ "test-backup" "test-inventory-machine" @@ -123,7 +119,7 @@ in test_machines_are_modules = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -132,7 +128,7 @@ in }; in { - expr = builtins.attrNames result.nixosModules; + expr = builtins.attrNames eval.config.nixosModules; expected = [ "clan-machine-test-backup" "clan-machine-test-inventory-machine" @@ -141,7 +137,7 @@ in test_buildClan_all_machines = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -153,7 +149,7 @@ in }; in { - expr = builtins.attrNames result.nixosConfigurations; + expr = builtins.attrNames eval.config.nixosConfigurations; expected = [ "machine1" "machine2" @@ -162,7 +158,7 @@ in test_buildClan_specialArgs = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -178,13 +174,13 @@ in }; in { - expr = result.nixosConfigurations.machine2.config.networking.hostName; + expr = eval.config.nixosConfigurations.machine2.config.networking.hostName; expected = "dream2nix"; }; test_buildClan_darwin_machines = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -201,10 +197,10 @@ in }; in { - inherit result; + result = eval; expr = { - nixos = builtins.attrNames result.nixosConfigurations; - darwin = builtins.attrNames result.darwinConfigurations; + nixos = builtins.attrNames eval.config.nixosConfigurations; + darwin = builtins.attrNames eval.config.darwinConfigurations; }; expected = { nixos = [ @@ -217,7 +213,7 @@ in test_buildClan_all_machines_laziness = let - result = buildClan { + eval = buildClan { self = { inputs = { }; }; @@ -228,7 +224,7 @@ in }; in { - expr = builtins.attrNames result.nixosConfigurations; + expr = builtins.attrNames eval.config.nixosConfigurations; expected = [ "machine1" ];