Add Maple Mono Nerd Font and custom theme support to Forgejo

This commit is contained in:
Root User 2026-02-12 22:05:17 +01:00
parent 387fb668b3
commit ff1d6b0829
Signed by: root
GPG key ID: 087F0A95E5766D72
3 changed files with 70 additions and 0 deletions

View file

@ -8,6 +8,23 @@
cfg = config.services.forgejo;
srv = cfg.settings.server;
choose = paths: builtins.head (builtins.filter (p: builtins.pathExists p) paths);
mapleZip = pkgs.fetchurl {
url = "https://github.com/subframe7536/maple-font/releases/download/v7.9/MapleMonoNormal-NF-unhinted.zip";
sha256 = "1j8bh8fzrnrj4348xj8l1jpbchbblhi2a7gryarf2mi88xr1yc3f";
};
# Add a runCommand that unpacks the downloaded zip and exposes a stable ttf path
mapleFonts = pkgs.runCommand "maple-fonts" {buildInputs = [pkgs.unzip];} ''
mkdir -p $out/tmp
unzip -q ${mapleZip} -d $out/tmp
f="$(find $out/tmp -type f -name '*.ttf' | head -n1)"
if [ -z "$f" ]; then
echo "no ttf found" >&2
exit 1
fi
mkdir -p $out/fonts
cp "$f" $out/fonts/MapleMonoNerd.ttf
'';
in {
options.local = {
hostname = lib.mkOption {
@ -100,8 +117,30 @@ in {
# ENABLED = false;
# };
};
settings.ui = {
DEFAULT_THEME = "custom";
THEMES = "forgejo-auto,forgejo-light,forgejo-dark,custom";
};
};
systemd.tmpfiles.rules = [
"d '${config.services.forgejo.customDir}/templates' - forgejo forgejo - -"
"d '${config.services.forgejo.customDir}/public' - forgejo forgejo - -"
"d '${config.services.forgejo.customDir}/public/assets' - forgejo forgejo - -"
"d '${config.services.forgejo.customDir}/public/assets/css' - forgejo forgejo - -"
# ensure fonts directory exists
"d '${config.services.forgejo.customDir}/public/assets/fonts' - forgejo forgejo - -"
# install the TTF from the Nix store into the Forgejo customDir
"C+ '${config.services.forgejo.customDir}/public/assets/fonts/MapleMonoNerd.ttf' - forgejo forgejo - ${mapleFonts}/fonts/MapleMonoNerd.ttf"
"C+ '${config.services.forgejo.customDir}/public/assets/css/theme-custom.css' - forgejo forgejo - ${
../styling/forgejo/theme-custom.css
}"
"C+ '${config.services.forgejo.customDir}/templates/home.tmpl' - forgejo forgejo - ${
../styling/forgejo/home.tmpl
}"
];
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [3000];