fix forge theme: bake css into static root via STATIC_ROOT_PATH

This commit is contained in:
damocles 2026-05-20 19:55:53 +02:00
parent 0873159b9e
commit 30c7274cc7

View file

@ -108,6 +108,19 @@ in
privateNetwork = false; privateNetwork = false;
config = config =
{ pkgs, ... }: { pkgs, ... }:
let
# Build a custom static-root that is the standard forgejo data
# output with our theme CSS added. Using STATIC_ROOT_PATH instead
# of tmpfiles / bind-mounts means the theme is always present in
# the nix store — no separate hive-forge container rebuild needed,
# and no persistent-state directory involved.
staticRootWithTheme = pkgs.runCommand "forgejo-static-with-theme" { } ''
cp -r ${cfg.package.data}/. $out/
mkdir -p $out/public/assets/css
cp ${../forge-theme/theme-catppuccin-vibec0re.css} \
$out/public/assets/css/theme-catppuccin-vibec0re.css
'';
in
{ {
system.stateVersion = "25.11"; system.stateVersion = "25.11";
services.forgejo = { services.forgejo = {
@ -125,6 +138,9 @@ in
SSH_LISTEN_PORT = cfg.sshPort; SSH_LISTEN_PORT = cfg.sshPort;
BUILTIN_SSH_SERVER_USER = "git"; BUILTIN_SSH_SERVER_USER = "git";
DISABLE_SSH = false; DISABLE_SSH = false;
# Point forgejo at our extended static root that includes
# the custom theme CSS baked straight into the nix store.
STATIC_ROOT_PATH = staticRootWithTheme;
}; };
# Registration off — operator seeds agent users via # Registration off — operator seeds agent users via
# `nixos-container run hive-forge -- forgejo admin # `nixos-container run hive-forge -- forgejo admin
@ -146,10 +162,6 @@ in
migrations.ALLOW_LOCALNETWORKS = true; migrations.ALLOW_LOCALNETWORKS = true;
log.LEVEL = "Warn"; log.LEVEL = "Warn";
ui = { ui = {
# Catppuccin Mocha theme shipped as a nix-managed CSS file.
# The tmpfiles rule below symlinks the file into the custom
# dir before forgejo starts, so a container rebuild always
# picks up CSS changes without touching persistent state.
DEFAULT_THEME = "catppuccin-vibec0re"; DEFAULT_THEME = "catppuccin-vibec0re";
THEMES = "catppuccin-vibec0re,forgejo-auto,forgejo-light,forgejo-dark,gitea-auto,gitea-light,gitea-dark"; THEMES = "catppuccin-vibec0re,forgejo-auto,forgejo-light,forgejo-dark,gitea-auto,gitea-light,gitea-dark";
}; };
@ -167,13 +179,6 @@ in
}; };
}; };
environment.systemPackages = [ pkgs.forgejo ]; environment.systemPackages = [ pkgs.forgejo ];
# Deploy the Catppuccin Mocha theme CSS into forgejo's custom
# public assets directory. Using a symlink (L+) so container
# rebuilds automatically reflect CSS edits without extra copies.
systemd.tmpfiles.rules = [
"d /var/lib/forgejo/custom/public/assets/css 0755 forgejo forgejo -"
"C+ /var/lib/forgejo/custom/public/assets/css/theme-catppuccin-vibec0re.css 0644 forgejo forgejo - ${../forge-theme/theme-catppuccin-vibec0re.css}"
];
}; };
}; };