nix-gitea-themes/module.nix

41 lines
1.3 KiB
Nix
Raw Normal View History

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
find "${theme-package}/share/gitea/public/assets/css" -name '*.css' -exec install -Dm444 -t "${giteaCfg.customDir}/public/assets/css/" \;
find "${theme-package}/share/gitea/public/assets/css" -name '*.css' -exec install -Dm444 -t "${giteaCfg.customDir}/public/css/" \;
'') (lib.attrValues cfg);
2024-04-09 00:39:34 +02:00
};
};
}