2024-04-09 00:39:34 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
2024-04-09 01:19:01 +02:00
|
|
|
cfg = config.services.gitea-themes;
|
2024-04-09 00:39:34 +02:00
|
|
|
giteaCfg = config.services.gitea;
|
|
|
|
in
|
|
|
|
{
|
2024-04-09 01:19:01 +02:00
|
|
|
options.services.gitea-themes = lib.mkOption {
|
|
|
|
description = ''
|
|
|
|
Derivations containing gitea themes to install.
|
|
|
|
|
|
|
|
The theme should be named `theme-<name>.css`, and reside in `$out/share/gitea/public/assets/css/`.
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
type = with lib.types; attrsOf path;
|
2024-04-09 00:39:34 +02:00
|
|
|
};
|
|
|
|
|
2024-04-09 01:19:01 +02:00
|
|
|
config = lib.mkIf (cfg != { }) {
|
|
|
|
services.gitea.settings.ui.THEMES = lib.strings.concatStringsSep "," ([
|
2024-04-09 00:39:34 +02:00
|
|
|
"gitea"
|
|
|
|
"arc-green"
|
2024-04-09 01:19:01 +02:00
|
|
|
] ++ lib.attrNames cfg);
|
2024-04-09 00:39:34 +02:00
|
|
|
|
2024-04-09 01:19:01 +02:00
|
|
|
systemd.services.install-gitea-themes = {
|
|
|
|
description = "Install gitea themes in gitea's CUSTOM_DIR";
|
2024-04-09 00:39:34 +02:00
|
|
|
wantedBy = [ "gitea.service" ];
|
|
|
|
requiredBy = [ "gitea.service" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
User = giteaCfg.user;
|
|
|
|
Group = giteaCfg.group;
|
|
|
|
};
|
2024-04-09 01:19:01 +02:00
|
|
|
script = lib.concatMapStringsSep "\n" (theme-package: ''
|
2024-04-09 00:39:34 +02:00
|
|
|
mkdir -p "${giteaCfg.customDir}/public/assets/css"
|
2024-04-09 01:19:01 +02:00
|
|
|
ln -s "${theme-package}/share/gitea/public/assets/css/*.css" "${giteaCfg.customDir}/public/assets/css/" ||:
|
|
|
|
ln -s "${theme-package}/share/gitea/public/css/*.css" "${giteaCfg.customDir}/public/css/" ||:
|
|
|
|
'') (lib.attrValues cfg);
|
2024-04-09 00:39:34 +02:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|