chore(checks/inventory): doogfood 'clan' flake-parts module into the test, instead of custom inventory logic
This commit is contained in:
@@ -7,40 +7,44 @@
|
|||||||
# - clan.service modules
|
# - clan.service modules
|
||||||
name = "dummy-inventory-test";
|
name = "dummy-inventory-test";
|
||||||
|
|
||||||
inventory.directory = ./.;
|
clanSettings = {
|
||||||
inventory.inventory = {
|
self = ./.;
|
||||||
machines.peer1 = { };
|
};
|
||||||
machines.admin1 = { };
|
clan = {
|
||||||
services = {
|
inventory = {
|
||||||
legacy-module.default = {
|
machines.peer1 = { };
|
||||||
roles.peer.machines = [ "peer1" ];
|
machines.admin1 = { };
|
||||||
roles.admin.machines = [ "admin1" ];
|
services = {
|
||||||
|
legacy-module.default = {
|
||||||
|
roles.peer.machines = [ "peer1" ];
|
||||||
|
roles.admin.machines = [ "admin1" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
instances."test" = {
|
||||||
|
module.name = "new-service";
|
||||||
|
roles.peer.machines.peer1 = { };
|
||||||
};
|
};
|
||||||
};
|
|
||||||
instances."test" = {
|
|
||||||
module.name = "new-service";
|
|
||||||
roles.peer.machines.peer1 = { };
|
|
||||||
};
|
|
||||||
|
|
||||||
modules = {
|
modules = {
|
||||||
legacy-module = ./legacy-module;
|
legacy-module = ./legacy-module;
|
||||||
new-service = {
|
new-service = {
|
||||||
_class = "clan.service";
|
_class = "clan.service";
|
||||||
manifest.name = "new-service";
|
manifest.name = "new-service";
|
||||||
roles.peer = { };
|
roles.peer = { };
|
||||||
perMachine = {
|
perMachine = {
|
||||||
nixosModule = {
|
nixosModule = {
|
||||||
# This should be generated by:
|
# This should be generated by:
|
||||||
# ./pkgs/scripts/update-vars.py inventory-test-framework-compatibility-test
|
# ./pkgs/scripts/update-vars.py inventory-test-framework-compatibility-test
|
||||||
clan.core.vars.generators.new-service = {
|
clan.core.vars.generators.new-service = {
|
||||||
files.hello = {
|
files.hello = {
|
||||||
secret = false;
|
secret = false;
|
||||||
deploy = true;
|
deploy = true;
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
# This is a dummy script that does nothing
|
||||||
|
echo "This is a dummy script" > $out/hello
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
script = ''
|
|
||||||
# This is a dummy script that does nothing
|
|
||||||
echo "This is a dummy script" > $out/hello
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2,37 +2,62 @@ test:
|
|||||||
{ pkgs, self, ... }:
|
{ pkgs, self, ... }:
|
||||||
let
|
let
|
||||||
inherit (pkgs) lib;
|
inherit (pkgs) lib;
|
||||||
inherit (lib) mkOption flip mapAttrs;
|
inherit (lib)
|
||||||
inherit (lib.types) path raw;
|
mkOption
|
||||||
inherit (self.clanLib) buildClan;
|
flip
|
||||||
|
mapAttrs
|
||||||
|
types
|
||||||
|
;
|
||||||
nixos-lib = import (pkgs.path + "/nixos/lib") { };
|
nixos-lib = import (pkgs.path + "/nixos/lib") { };
|
||||||
in
|
in
|
||||||
(nixos-lib.runTest (
|
(nixos-lib.runTest (
|
||||||
{ config, ... }:
|
{ config, ... }:
|
||||||
let
|
let
|
||||||
result = buildClan {
|
clanFlakeResult = config.clan;
|
||||||
inventory = config.inventory.inventory;
|
|
||||||
# TODO: make directory argument optional in buildInventory
|
|
||||||
directory = config.inventory.directory;
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ test ];
|
imports = [ test ];
|
||||||
options = {
|
options = {
|
||||||
inventory.inventory = mkOption {
|
clanSettings = mkOption {
|
||||||
description = "Inventory of machines and services";
|
default = { };
|
||||||
type = raw;
|
type = types.submodule {
|
||||||
|
options = {
|
||||||
|
clan-core = mkOption { default = self; };
|
||||||
|
self = mkOption {
|
||||||
|
default = throw ''
|
||||||
|
Clan testing: 'clanSettings.self' is required to be set explizitly during testing.
|
||||||
|
|
||||||
|
It is recommended to set 'clanSettings.self' during testing to the directory where the test lives in i.e. './.'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
nixpkgs = mkOption { default = self.inputs.nixpkgs; };
|
||||||
|
nix-darwin = mkOption { default = self.inputs.nix-darwin; };
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
inventory.directory = mkOption {
|
|
||||||
description = "Directory which contains the vars";
|
clan = mkOption {
|
||||||
type = path;
|
default = { };
|
||||||
|
type = types.submoduleWith {
|
||||||
|
specialArgs = {
|
||||||
|
inherit (config.clanSettings)
|
||||||
|
clan-core
|
||||||
|
self
|
||||||
|
nixpkgs
|
||||||
|
nix-darwin
|
||||||
|
;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
self.clanLib.buildClanModule.flakePartsModule
|
||||||
|
];
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = {
|
||||||
nodes = flip mapAttrs result.clanInternals.inventoryClass.machines (
|
nodes = flip mapAttrs clanFlakeResult.clanInternals.inventoryClass.machines (
|
||||||
machineName: attrs: {
|
machineName: attrs: {
|
||||||
imports = attrs.machineImports ++ [ self.nixosModules.clanCore ];
|
imports = attrs.machineImports ++ [ self.nixosModules.clanCore ];
|
||||||
clan.core.settings.directory = "${config.inventory.directory}";
|
clan.core.settings.directory = "${config.clan.directory}";
|
||||||
clan.core.settings.machine.name = machineName;
|
clan.core.settings.machine.name = machineName;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
@@ -69,4 +94,5 @@ in
|
|||||||
node.specialArgs.self = self;
|
node.specialArgs.self = self;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
)).config.result
|
))
|
||||||
|
# .config.result
|
||||||
|
|||||||
Reference in New Issue
Block a user