Revert "Merge pull request 'chore(buildClan): move machineClass option into inventory.machines submodule' (#3259) from hsjobeki/clan-core:buildclan-cleanup into main"

This reverts commit 11ba13df67, reversing
changes made to 04f9aa3ae0.
This commit is contained in:
Jörg Thalheim
2025-04-09 16:08:39 +02:00
parent b66317af04
commit 62dfb23e41
5 changed files with 29 additions and 34 deletions

View File

@@ -5,9 +5,6 @@
"description": "A nice thing", "description": "A nice thing",
"icon": "./path/to/icon.png", "icon": "./path/to/icon.png",
"tags": ["1", "2", "3"] "tags": ["1", "2", "3"]
},
"test-darwin-machine": {
"machineClass": "darwin"
} }
}, },
"services": { "services": {

View File

@@ -164,18 +164,16 @@ let
}; };
}; };
allMachines = inventoryClass.machines; allMachines = inventory.machines or { } // machines;
machineClasses = lib.mapAttrs ( machineClass = lib.mapAttrs (name: _: inventory.machineClass.${name} or "nixos") allMachines;
name: _: inventory.machines.${name}.machineClass or "nixos"
) allMachines;
configurations = lib.mapAttrs ( configurations = lib.mapAttrs (
name: _: moduleSystemConstructor.${machineClasses.${name}} { inherit name; } name: _: moduleSystemConstructor.${machineClass.${name}} { inherit name; }
) allMachines; ) allMachines;
nixosConfigurations = lib.filterAttrs (name: _: machineClasses.${name} == "nixos") configurations; nixosConfigurations = lib.filterAttrs (name: _: machineClass.${name} == "nixos") configurations;
darwinConfigurations = lib.filterAttrs (name: _: machineClasses.${name} == "darwin") configurations; darwinConfigurations = lib.filterAttrs (name: _: machineClass.${name} == "darwin") configurations;
# This instantiates NixOS for each system that we support: # This instantiates NixOS for each system that we support:
# configPerSystem = <system>.<machine>.nixosConfiguration # configPerSystem = <system>.<machine>.nixosConfiguration
@@ -186,7 +184,7 @@ let
lib.nameValuePair system ( lib.nameValuePair system (
lib.mapAttrs ( lib.mapAttrs (
name: _: name: _:
moduleSystemConstructor.${machineClasses.${name}} { moduleSystemConstructor.${machineClass.${name}} {
inherit name system; inherit name system;
pkgs = pkgsFor.${system}; pkgs = pkgsFor.${system};
} }
@@ -201,7 +199,7 @@ let
lib.nameValuePair system ( lib.nameValuePair system (
lib.mapAttrs ( lib.mapAttrs (
name: _: args: name: _: args:
moduleSystemConstructor.${machineClasses.${name}} ( moduleSystemConstructor.${machineClass.${name}} (
args args
// { // {
inherit name system; inherit name system;

View File

@@ -210,16 +210,14 @@ in
meta.name = "test"; meta.name = "test";
machines.machine1 = { }; machines.machine1 = { };
inventory.machines.machine2 = { machines.machine2 = { };
machineClass = "darwin"; machines.machine3 = { };
};
inventory.machines.machine3 = { inventory.machineClass.machine2 = "darwin";
machineClass = "nixos"; inventory.machineClass.machine3 = "nixos";
};
}; };
in in
{ {
inherit result;
expr = { expr = {
nixos = builtins.attrNames result.nixosConfigurations; nixos = builtins.attrNames result.nixosConfigurations;
darwin = builtins.attrNames result.darwinConfigurations; darwin = builtins.attrNames result.darwinConfigurations;
@@ -243,6 +241,7 @@ in
meta.name = "test"; meta.name = "test";
machines.machine1.non_existent_option = throw "eval error"; machines.machine1.non_existent_option = throw "eval error";
inventory.machines.machine1.other_non_existent_option = throw "different eval error";
}; };
in in
{ {

View File

@@ -243,19 +243,6 @@ in
options = { options = {
inherit (metaOptionsWith name) name description icon; inherit (metaOptionsWith name) name description icon;
machineClass = lib.mkOption {
default = "nixos";
type = types.enum [
"nixos"
"darwin"
];
description = ''
The module system that should be used to construct the machine
Set this to `darwin` for macOS machines
'';
};
tags = lib.mkOption { tags = lib.mkOption {
description = '' description = ''
List of tags for the machine. List of tags for the machine.
@@ -291,6 +278,21 @@ in
); );
}; };
machineClass = lib.mkOption {
default = { };
type = types.attrsOf (
types.enum [
"nixos"
"darwin"
]
);
description = ''
The module system that should be used to construct the machine
Set this to `darwin` for macOS machines
'';
};
instances = lib.mkOption { instances = lib.mkOption {
# Keep as internal until all de-/serialization issues are resolved # Keep as internal until all de-/serialization issues are resolved
visible = false; visible = false;
@@ -364,7 +366,6 @@ in
else else
lib.warn "Inventory.instances and related features are still under development. Please use with care." v; lib.warn "Inventory.instances and related features are still under development. Please use with care." v;
}; };
services = lib.mkOption { services = lib.mkOption {
description = '' description = ''
Services of the inventory. Services of the inventory.

View File

@@ -16,7 +16,6 @@ class Machine(TypedDict):
deploy: NotRequired[MachineDeploy] deploy: NotRequired[MachineDeploy]
description: NotRequired[str] description: NotRequired[str]
icon: NotRequired[str] icon: NotRequired[str]
machineClass: NotRequired[Literal["nixos", "darwin"]]
name: NotRequired[str] name: NotRequired[str]
tags: NotRequired[list[str]] tags: NotRequired[list[str]]
@@ -30,6 +29,7 @@ Service = dict[str, Any]
class Inventory(TypedDict): class Inventory(TypedDict):
machineClass: NotRequired[dict[str, Any]]
machines: NotRequired[dict[str, Machine]] machines: NotRequired[dict[str, Machine]]
meta: NotRequired[Meta] meta: NotRequired[Meta]
modules: NotRequired[dict[str, Any]] modules: NotRequired[dict[str, Any]]