Add Maple Mono Nerd Font and custom theme support to Forgejo
This commit is contained in:
parent
387fb668b3
commit
ff1d6b0829
3 changed files with 70 additions and 0 deletions
13
nix-system-configs/modules/styling/forgejo/home.tmpl
Normal file
13
nix-system-configs/modules/styling/forgejo/home.tmpl
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
[[:Template:Template "base/head" .]]
|
||||||
|
<div role="main" aria-label="[[:Template:If .IsSigned]][[:Template:Ctx.Locale.Tr "dashboard"]][[:Template:Else]][[:Template:Ctx.Locale.Tr "home"]][[:Template:End]]" class="page-content home">
|
||||||
|
<div class="tw-mb-8 tw-px-8">
|
||||||
|
<div class="center">
|
||||||
|
<div class="hero">
|
||||||
|
<h1 class="ui icon header title">
|
||||||
|
Forgejo hosted on NixOS!
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
[[:Template:Template "base/footer" .]]
|
||||||
18
nix-system-configs/modules/styling/forgejo/theme-custom.css
Normal file
18
nix-system-configs/modules/styling/forgejo/theme-custom.css
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
@font-face {
|
||||||
|
font-family: 'Maple Mono NF';
|
||||||
|
src: url('/assets/fonts/MapleMonoNerd.ttf') format('truetype');
|
||||||
|
font-weight: normal;
|
||||||
|
font-style: normal;
|
||||||
|
font-display: swap;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* import base Forgejo theme so we only override what we need */
|
||||||
|
@import "./theme-forgejo-auto.css";
|
||||||
|
|
||||||
|
:root {
|
||||||
|
/* prefer the Maple Mono Nerd Font for monospace usage */
|
||||||
|
--fonts-monospace: 'Maple Mono NF', var(--fonts-monospace);
|
||||||
|
/* if you want the UI proportional font to also use Maple, set --fonts-override */
|
||||||
|
/* --fonts-override: 'Maple Mono NF', var(--fonts-override); */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -8,6 +8,23 @@
|
||||||
cfg = config.services.forgejo;
|
cfg = config.services.forgejo;
|
||||||
srv = cfg.settings.server;
|
srv = cfg.settings.server;
|
||||||
choose = paths: builtins.head (builtins.filter (p: builtins.pathExists p) paths);
|
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 {
|
in {
|
||||||
options.local = {
|
options.local = {
|
||||||
hostname = lib.mkOption {
|
hostname = lib.mkOption {
|
||||||
|
|
@ -100,8 +117,30 @@ in {
|
||||||
# ENABLED = false;
|
# 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.
|
# Open ports in the firewall.
|
||||||
networking.firewall.allowedTCPPorts = [3000];
|
networking.firewall.allowedTCPPorts = [3000];
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue