Interfaces: unclutter meta interface, file conflict position tracking

This commit is contained in:
Johannes Kirschbauer
2024-10-04 13:47:46 +02:00
parent 091ff4e736
commit 71d3d03b43
4 changed files with 50 additions and 32 deletions

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,25 @@
{ lib, ... }:
let
types = lib.types;
metaOptions = {
name = lib.mkOption { type = types.nullOr 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
'';
};
};
in
{
options = metaOptions;
}