Merge pull request 'chore(checks/inventory): doogfood 'clan' flake-parts module into the test, instead of custom inventory logic' (#3279) from hsjobeki/clan-core:clan-services into main
Reviewed-on: https://git.clan.lol/clan/clan-core/pulls/3279
This commit is contained in:
@@ -11,7 +11,8 @@
|
|||||||
{
|
{
|
||||||
name = "data-mesher";
|
name = "data-mesher";
|
||||||
|
|
||||||
inventory = {
|
clan = {
|
||||||
|
directory = ./.;
|
||||||
inventory = {
|
inventory = {
|
||||||
machines = lib.genAttrs machines (_: { });
|
machines = lib.genAttrs machines (_: { });
|
||||||
services = {
|
services = {
|
||||||
@@ -22,7 +23,6 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
directory = ./.;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaults =
|
defaults =
|
||||||
|
|||||||
@@ -7,8 +7,9 @@
|
|||||||
# - clan.service modules
|
# - clan.service modules
|
||||||
name = "dummy-inventory-test";
|
name = "dummy-inventory-test";
|
||||||
|
|
||||||
inventory.directory = ./.;
|
clan = {
|
||||||
inventory.inventory = {
|
directory = ./.;
|
||||||
|
inventory = {
|
||||||
machines.peer1 = { };
|
machines.peer1 = { };
|
||||||
machines.admin1 = { };
|
machines.admin1 = { };
|
||||||
services = {
|
services = {
|
||||||
@@ -47,6 +48,7 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
|
||||||
testScript =
|
testScript =
|
||||||
{ nodes, ... }:
|
{ nodes, ... }:
|
||||||
|
|||||||
@@ -2,37 +2,54 @@ 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; };
|
||||||
|
nixpkgs = mkOption { default = self.inputs.nixpkgs; };
|
||||||
|
nix-darwin = mkOption { default = self.inputs.nix-darwin; };
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
clan = mkOption {
|
||||||
|
default = { };
|
||||||
|
type = types.submoduleWith {
|
||||||
|
specialArgs = {
|
||||||
|
inherit (config.clanSettings)
|
||||||
|
clan-core
|
||||||
|
nixpkgs
|
||||||
|
nix-darwin
|
||||||
|
;
|
||||||
|
};
|
||||||
|
modules = [
|
||||||
|
self.clanLib.buildClanModule.flakePartsModule
|
||||||
|
];
|
||||||
};
|
};
|
||||||
inventory.directory = mkOption {
|
|
||||||
description = "Directory which contains the vars";
|
|
||||||
type = path;
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
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;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user