Merge pull request 'Interfaces: unclutter meta interface, file conflict position tracking' (#2198) from hsjobeki/clan-core:hsjobeki-roles-interface into main

This commit is contained in:
clan-bot
2024-10-04 12:38:53 +00:00
4 changed files with 57 additions and 32 deletions

View File

@@ -63,17 +63,10 @@ in
description = ''
Global information about the clan.
'';
type = types.nullOr (
types.submodule {
options = {
name = lib.mkOption {
type = types.nullOr types.str;
description = "Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.";
type = types.deferredModuleWith {
staticModules = [ ../inventory/build-inventory/meta-interface.nix ];
};
};
}
);
default = null;
default = { };
};
pkgsForSystem = lib.mkOption {

View File

@@ -222,7 +222,12 @@ in
{
imports = [
# Merge the inventory file
{ inventory = inventoryLoaded; }
{
inventory = _: {
_file = inventoryFile;
config = inventoryLoaded;
};
}
# TODO: Figure out why this causes infinite recursion
{
inventory.machines = lib.optionalAttrs (builtins.pathExists "${directory}/machines") (
@@ -235,7 +240,9 @@ in
inventory.machines = lib.mapAttrs (_n: _: { }) config.machines;
}
# Merge the meta attributes from the buildClan function
{ inventory.meta = if config.meta != null then config.meta else { }; }
#
# config.inventory.meta <- config.meta
{ inventory.meta = config.meta; }
];
inherit nixosConfigurations;

View File

@@ -1,24 +1,7 @@
{ config, lib, ... }:
{ lib, ... }:
let
types = lib.types;
metaOptions = {
name = lib.mkOption { type = types.str; };
description = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = ''
Optional freeform description
'';
};
icon = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = ''
Under construction, will be used for the UI
'';
};
};
metaOptionsWith = name: {
name = lib.mkOption {
type = types.str;
@@ -45,6 +28,8 @@ let
moduleConfig = lib.mkOption {
default = { };
# TODO: use types.deferredModule
# clan.borgbackup MUST be defined as submodule
type = types.attrsOf types.anything;
description = ''
Configuration of the specific clanModule.
@@ -102,6 +87,7 @@ let
};
in
{
imports = [ ./assertions.nix ];
options = {
assertions = lib.mkOption {
@@ -110,7 +96,13 @@ in
visible = false;
default = [ ];
};
meta = metaOptions;
meta = lib.mkOption {
type = lib.types.submoduleWith {
modules = [
./meta-interface.nix
];
};
};
machines = lib.mkOption {
description = ''
@@ -189,6 +181,7 @@ in
type = types.attrsOf (
types.attrsOf (
types.submodule (
# instance name
{ name, ... }:
{
options.meta = metaOptionsWith name;

View File

@@ -0,0 +1,32 @@
{ lib, ... }:
let
types = lib.types;
metaOptions = {
name = lib.mkOption {
type = types.str;
description = ''
Name of the clan.
Needs to be (globally) unique, as this determines the folder name where the flake gets downloaded to.
'';
};
description = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = ''
Optional freeform description
'';
};
icon = lib.mkOption {
default = null;
type = types.nullOr types.str;
description = ''
Under construction, will be used for the UI
'';
};
};
in
{
options = metaOptions;
}