feat: default labels preset for Capytal's workflow

This commit is contained in:
Guz
2024-09-18 18:09:26 -03:00
parent 469f9d99d7
commit 8219cf746c
6 changed files with 257 additions and 30 deletions

View File

@@ -23,6 +23,40 @@ in {
type = attrsOf anything;
default = {};
};
options = {
label = mkOption {
type = attrsOf (attrsOf (submodule ({
config,
lib,
...
}:
with lib;
with lib.types; {
options = {
name = mkOption {
type = nullOr str;
default = null;
};
exclusive = mkOption {
type = bool;
default = false;
};
color = mkOption {
type = str;
};
description = mkOption {
type = str;
default = "";
};
priority = mkOption {
type = nullOr (enum ["low" "medium" "high" "critical"]);
default = null;
};
};
})));
default = {};
};
};
templates = {
header = mkOption {
type = nullOr fileType;
@@ -81,16 +115,9 @@ in {
else {source = theme;};
assetsDir = "${forgejoConfig.customDir}/public/assets";
templatesDir = "${forgejoConfig.customDir}/templates";
optionsDir = "${forgejoConfig.customDir}/options";
in
{
"${templatesDir}/custom/header.tmpl" =
mkIf (!(isNull customization.templates.header))
(fileTypeToHomeFile customization.templates.header);
"${templatesDir}/home.tmpl" =
mkIf (!(isNull customization.templates.home))
(fileTypeToHomeFile customization.templates.home);
"${assetsDir}/img/logo.svg" =
mkIf (!(isNull customization.logo.svg))
(fileTypeToHomeFile customization.logo.svg);
@@ -106,7 +133,34 @@ in {
"${assetsDir}/img/favicon.png" =
mkIf (!(isNull customization.favicon.png))
(fileTypeToHomeFile customization.favicon.png);
"${templatesDir}/custom/header.tmpl" =
mkIf (!(isNull customization.templates.header))
(fileTypeToHomeFile customization.templates.header);
"${templatesDir}/home.tmpl" =
mkIf (!(isNull customization.templates.home))
(fileTypeToHomeFile customization.templates.home);
}
// (lib.attrsets.mapAttrs'
(ln: lv:
lib.attrsets.nameValuePair "${optionsDir}/label/${ln}.yaml" {
text = toJSON {
labels = attrValues (mapAttrs
(n: v: {
name =
if isNull v.name
then n
else v.name;
exclusive = v.exclusive;
color = v.color;
description = v.description;
priority = v.priority;
})
lv);
};
})
customization.options.label)
// (lib.attrsets.mapAttrs'
(n: v: lib.attrsets.nameValuePair "${assetsDir}/${n}" v)
customization.assets)

View File

@@ -42,6 +42,18 @@ in {
default = "https://localhost:${toString cfg.settings.server.HTTP_PORT}";
};
};
project = {
PROJECT_BOARD_BASIC_KANBAN_TYPE = mkOption {
type = listOf str;
defaut = ["To Do" "In Progress" "Done"];
apply = t: initList t;
};
PROJECT_BOARD_BUG_TRIAGE_TYPE = mkOption {
type = listOf str;
defaut = ["Needs Triage" "High Priority" "Low Priority" "Closed"];
apply = t: initList t;
};
};
repository = {
DEFAULT_REPO_UNITS = mkOption {
type = listOf str;