Add: legacy support for implicitly creating machines through creating a directory

This will be deprecated as soon as the tests dont rely on this behavior anymore
This commit is contained in:
Johannes Kirschbauer
2024-08-03 12:04:23 +02:00
parent 5d12154f96
commit 79e15bff24

View File

@@ -81,7 +81,7 @@ let
(machines.${name} or { }) (machines.${name} or { })
# Inherit the inventory assertions ? # Inherit the inventory assertions ?
# { inherit (mergedInventory) assertions; } # { inherit (mergedInventory) assertions; }
{ imports = (serviceConfigs.${name} or [ ]); } { imports = serviceConfigs.${name} or [ ]; }
( (
{ {
# Settings # Settings
@@ -111,7 +111,38 @@ let
} // specialArgs; } // specialArgs;
}; };
allMachines = (inventory.machines or { } // config.machines or { }); # TODO: Will be deprecated
# We must migrate the tests, that create a settings.json to add a machine.
##################################################
testMachines =
lib.mapAttrs
(name: _: {
inherit name;
system = (machineSettings name).nixpkgs.hostSystem or null;
})
(
lib.filterAttrs (
machineName: _:
if builtins.pathExists "${directory}/machines/${machineName}/settings.json" then
lib.warn ''
The use of ./machines/<machine>/settings.json is deprecated.
If your settings.json is empty, you can safely remove it.
!!! Consider using the inventory system. !!!
File: ${directory + /machines/${machineName}/settings.json}
If there are still features missing in the inventory system, please open an issue on the clan-core repository.
'' true
else
false
) machinesDirs
);
machinesDirs = lib.optionalAttrs (builtins.pathExists "${directory}/machines") (
builtins.readDir (directory + /machines)
);
##################################################
allMachines = inventory.machines or { } // config.machines or { } // testMachines;
supportedSystems = [ supportedSystems = [
"x86_64-linux" "x86_64-linux"
@@ -166,7 +197,6 @@ let
(builtins.fromJSON (builtins.readFile inventoryFile)) (builtins.fromJSON (builtins.readFile inventoryFile))
else else
{ }; { };
in in
{ {
imports = [ imports = [