Chore(clanInternals): remove unused attributes

This commit is contained in:
Johannes Kirschbauer
2025-06-10 16:31:42 +02:00
parent 490a77ef54
commit 01a3151968
3 changed files with 37 additions and 52 deletions

View File

@@ -198,24 +198,21 @@ in
options = {
# Those options are interfaced by the CLI
# We don't specify the type here, for better performance.
inventory = lib.mkOption { type = lib.types.raw; };
# all exported clan templates from this clan
templates = lib.mkOption { type = lib.types.raw; };
# all exported clan modules from this clan
modules = lib.mkOption { type = lib.types.raw; };
# all inventory module schemas
inventoryFile = lib.mkOption { type = lib.types.raw; };
# The machine 'imports' generated by the inventory per machine
inventoryClass = lib.mkOption { type = lib.types.raw; };
evalServiceSchema = lib.mkOption { };
# clan-core's modules
clanModules = lib.mkOption { type = lib.types.raw; };
source = lib.mkOption { type = lib.types.raw; };
meta = lib.mkOption { type = lib.types.raw; };
# The machine 'imports' generated by the inventory per machine
inventoryClass = lib.mkOption { type = lib.types.raw; };
# TODO: remove all dependents in python, delete this option
inventory = lib.mkOption {
type = lib.types.raw;
apply = lib.warn "The 'clanInternals.inventory' option is deprecated, use 'clanInternals.inventoryClass' instead.";
};
secrets = lib.mkOption { type = lib.types.raw; };
clanLib = lib.mkOption { type = lib.types.raw; };
machines = lib.mkOption { type = lib.types.raw; };
all-machines-json = lib.mkOption { type = lib.types.raw; };
};
};
};

View File

@@ -133,24 +133,26 @@ let
) supportedSystems
);
inventoryFile = "${directory}/inventory.json";
inventoryLoaded =
if builtins.pathExists inventoryFile then
(builtins.fromJSON (builtins.readFile inventoryFile))
else
{ };
in
{
imports = [
# Merge the inventory file
(
{ ... }:
let
file = "${directory}/inventory.json";
inventoryLoaded =
if builtins.pathExists file then (builtins.fromJSON (builtins.readFile file)) else { };
in
{
inventory = _: {
_file = inventoryFile;
config = inventoryLoaded;
};
imports = [
{
inventory._inventoryFile = file;
}
];
inventory = inventoryLoaded;
}
)
{
# TODO: Figure out why this causes infinite recursion
inventory.machines = lib.optionalAttrs (builtins.pathExists "${directory}/machines") (
@@ -238,38 +240,18 @@ in
clanInternals = {
inherit inventoryClass;
# Endpoint that can be called to get a service schema
evalServiceSchema = clan-core.clanLib.evalServiceSchema config.self;
inventory = config.inventory;
# TODO: unify this interface
# We should have only clan.modules. (consistent with clan.templates)
inherit (clan-core) clanModules clanLib;
modules = config.modules;
inherit inventoryFile;
inherit (clan-core) clanModules;
templates = config.templates;
inventory = config.inventory;
# TODO: Remove this in about a month
# It is only here for backwards compatibility for people with older CLI versions
inventoryValuesPrios = inventoryClass.introspection;
meta = config.inventory.meta;
secrets = config.secrets;
source = "${clan-core}";
secrets = config.secrets;
# machine specifics
machines = configsPerSystem;
all-machines-json =
lib.trace "Your clan-cli and the clan-core input have incompatible versions" lib.mapAttrs
(
system: configs:
nixpkgs.legacyPackages.${system}.writers.writeJSON "machines.json" (
lib.mapAttrs (_: m: m.config.system.clan.deployment.data) configs
)
)
configsPerSystem;
};
};
}

View File

@@ -97,6 +97,12 @@ in
./assertions.nix
];
options = {
_inventoryFile = lib.mkOption {
type = types.path;
readOnly = true;
internal = true;
visible = false;
};
_legacyModules = lib.mkOption {
internal = true;
visible = false;