chore: clean up logic around clanInternals

This commit is contained in:
Johannes Kirschbauer
2025-06-26 16:12:35 +02:00
parent a95d39923e
commit 7d755d04b5
6 changed files with 32 additions and 60 deletions

View File

@@ -22,7 +22,7 @@
dependencies = [ dependencies = [
self self
pkgs.stdenv.drvPath 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); ] ++ builtins.map (i: i.outPath) (builtins.attrValues self.inputs);
closureInfo = pkgs.closureInfo { rootPaths = dependencies; }; closureInfo = pkgs.closureInfo { rootPaths = dependencies; };
in in
@@ -162,7 +162,7 @@
] ]
++ ++
# import the inventory generated nixosModules # import the inventory generated nixosModules
self.clanInternals.inventoryClass.machines.test-backup.machineImports; self.clan.clanInternals.inventoryClass.machines.test-backup.machineImports;
clan.core.settings.directory = ./.; clan.core.settings.directory = ./.;
}; };

View File

@@ -8,9 +8,9 @@ let
{ modulesPath, pkgs, ... }: { modulesPath, pkgs, ... }:
let let
dependencies = [ dependencies = [
self.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.toplevel
self.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.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.clan.deployment.file
pkgs.stdenv.drvPath pkgs.stdenv.drvPath
pkgs.bash.drvPath pkgs.bash.drvPath
pkgs.nixos-anywhere pkgs.nixos-anywhere

View File

@@ -46,7 +46,7 @@ in
inherit testFlake; inherit testFlake;
expr = expr =
testFlake.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config; testFlake.clan.clanInternals.inventoryClass.distributedServices.importedModulesEvaluated.self-wifi.config;
expected = 1; expected = 1;
# expr = { # expr = {

View File

@@ -22,11 +22,8 @@ in
options.flake = { options.flake = {
# Backwards compat # Backwards compat
clanInternals = lib.mkOption { clanInternals = lib.mkOption {
description = "Internals as used by the clan cli. Deprecated use clan.clanInternals"; description = "Internals as needed by the clan cli.";
visible = false;
readOnly = true;
default = config.flake.clan.clanInternals; default = config.flake.clan.clanInternals;
apply = lib.warn "Use clan.clanInternals instead";
}; };
# The one and only clan module # The one and only clan module
clan = lib.mkOption { clan = lib.mkOption {

View File

@@ -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"
];
}

View File

@@ -15,20 +15,19 @@ in
{ {
test_missing_self = test_missing_self =
let let
clan = buildClan { eval = buildClan {
meta.name = "test"; meta.name = "test";
directory = ./.; directory = ./.;
}; };
in in
{ {
inherit clan; expr = shallowForceAllAttributes eval.config;
expr = shallowForceAllAttributes clan;
expected = true; expected = true;
}; };
test_only_required = test_only_required =
let let
clan = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
outPath = ./.; outPath = ./.;
@@ -37,13 +36,13 @@ in
}; };
in in
{ {
expr = shallowForceAllAttributes clan; expr = shallowForceAllAttributes eval.config;
expected = true; expected = true;
}; };
test_all_simple = test_all_simple =
let let
config = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -55,13 +54,13 @@ in
}; };
in in
{ {
expr = config ? inventory; expr = eval.config ? inventory;
expected = true; expected = true;
}; };
test_outputs_clanInternals = test_outputs_clanInternals =
let let
config = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -72,15 +71,12 @@ in
directory = ./.; directory = ./.;
inventory.meta.name = "test"; inventory.meta.name = "test";
} }
./clan/module.nix
# Explicit output, usually defined by flake-parts
{ options.nixosConfigurations = lib.mkOption { type = lib.types.raw; }; }
]; ];
}; };
in in
{ {
expr = config.clanInternals.inventory.meta; inherit eval;
expr = eval.config.clanInternals.inventory.meta;
expected = { expected = {
description = null; description = null;
icon = null; icon = null;
@@ -90,7 +86,7 @@ in
test_fn_simple = test_fn_simple =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -99,13 +95,13 @@ in
}; };
in in
{ {
expr = lib.isAttrs result.clanInternals; expr = lib.isAttrs eval.config.clanInternals;
expected = true; expected = true;
}; };
test_fn_clan_core = test_fn_clan_core =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -114,7 +110,7 @@ in
}; };
in in
{ {
expr = builtins.attrNames result.nixosConfigurations; expr = builtins.attrNames eval.config.nixosConfigurations;
expected = [ expected = [
"test-backup" "test-backup"
"test-inventory-machine" "test-inventory-machine"
@@ -123,7 +119,7 @@ in
test_machines_are_modules = test_machines_are_modules =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -132,7 +128,7 @@ in
}; };
in in
{ {
expr = builtins.attrNames result.nixosModules; expr = builtins.attrNames eval.config.nixosModules;
expected = [ expected = [
"clan-machine-test-backup" "clan-machine-test-backup"
"clan-machine-test-inventory-machine" "clan-machine-test-inventory-machine"
@@ -141,7 +137,7 @@ in
test_buildClan_all_machines = test_buildClan_all_machines =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -153,7 +149,7 @@ in
}; };
in in
{ {
expr = builtins.attrNames result.nixosConfigurations; expr = builtins.attrNames eval.config.nixosConfigurations;
expected = [ expected = [
"machine1" "machine1"
"machine2" "machine2"
@@ -162,7 +158,7 @@ in
test_buildClan_specialArgs = test_buildClan_specialArgs =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -178,13 +174,13 @@ in
}; };
in in
{ {
expr = result.nixosConfigurations.machine2.config.networking.hostName; expr = eval.config.nixosConfigurations.machine2.config.networking.hostName;
expected = "dream2nix"; expected = "dream2nix";
}; };
test_buildClan_darwin_machines = test_buildClan_darwin_machines =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -201,10 +197,10 @@ in
}; };
in in
{ {
inherit result; result = eval;
expr = { expr = {
nixos = builtins.attrNames result.nixosConfigurations; nixos = builtins.attrNames eval.config.nixosConfigurations;
darwin = builtins.attrNames result.darwinConfigurations; darwin = builtins.attrNames eval.config.darwinConfigurations;
}; };
expected = { expected = {
nixos = [ nixos = [
@@ -217,7 +213,7 @@ in
test_buildClan_all_machines_laziness = test_buildClan_all_machines_laziness =
let let
result = buildClan { eval = buildClan {
self = { self = {
inputs = { }; inputs = { };
}; };
@@ -228,7 +224,7 @@ in
}; };
in in
{ {
expr = builtins.attrNames result.nixosConfigurations; expr = builtins.attrNames eval.config.nixosConfigurations;
expected = [ expected = [
"machine1" "machine1"
]; ];