Skip to content

Commit

Permalink
feat(nixos): add support for gitea/forgejo
Browse files Browse the repository at this point in the history
  • Loading branch information
Lichthagel committed May 20, 2024
1 parent d634461 commit c9b66cb
Showing 1 changed file with 82 additions and 0 deletions.
82 changes: 82 additions & 0 deletions modules/nixos/gitea-forgejo.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
{ config
, lib
, pkgs
, ...
}:
let
# theme = config.catppuccin.sources.gitea;
theme = pkgs.fetchzip {
url = "https://github.com/catppuccin/gitea/releases/download/v0.4.1/catppuccin-gitea.tar.gz";
sha256 = "sha256-14XqO1ZhhPS7VDBSzqW55kh6n5cFZGZmvRCtMEh8JPI=";
stripRoot = false;
};

mkForgeModule =
forge:
let
cfg = config.services.${forge}.catppuccin;
enable = cfg.enable && config.services.${forge}.enable;
in
{
options.services.${forge}.catppuccin = lib.ctp.mkCatppuccinOpt forge // {
accent = lib.ctp.mkAccentOpt forge;
};

config = lib.mkIf enable {
systemd.services.${forge}.preStart =
let
customDir = config.services.${forge}.customDir;
baseDir =
if lib.versionAtLeast config.services.${forge}.package.version "1.21.0" then
"${customDir}/public/assets"
else
"${customDir}/public";
in
lib.mkAfter ''
rm -rf ${baseDir}/css
mkdir -p ${baseDir}
ln -sf ${theme} ${baseDir}/css
'';

services.${forge}.settings.ui = {
DEFAULT_THEME = "catppuccin-${cfg.flavour}-${cfg.accent}";
THEMES =
let
builtinThemes = {
gitea = [
"auto"
"gitea"
"arc-greeen"
];
forgejo = [
"forgejo-auto"
"forgejo-light"
"forgejo-dark"
"gitea-auto"
"gitea-light"
"gitea-dark"
"forgejo-auto-deuteranopia-protanopia"
"forgejo-light-deuteranopia-protanopia"
"forgejo-dark-deuteranopia-protanopia"
"forgejo-auto-tritanopia"
"forgejo-light-tritanopia"
"forgejo-dark-tritanopia"
];
};
in
builtins.concatStringsSep "," (
builtinThemes.${forge}
++ (map (name: lib.removePrefix "theme-" (lib.removeSuffix ".css" name)) (
builtins.attrNames (builtins.readDir theme)
))
);
};
};
};
in
{
imports = [
(mkForgeModule "gitea")
(mkForgeModule "forgejo")
];
}

0 comments on commit c9b66cb

Please sign in to comment.