chore: clean up logic around clanInternals

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

View File

@@ -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 = ./.;
};

View File

@@ -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

View File

@@ -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 = {

View File

@@ -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 {

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 =
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"
];