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 authored and isabelroses committed Jan 6, 2025
1 parent 8eada39 commit 46c4804
Show file tree
Hide file tree
Showing 6 changed files with 116 additions and 4 deletions.
12 changes: 9 additions & 3 deletions modules/lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ let
in

lib.makeExtensible (ctp: {
types = {
flavor = types.enum [
consts = {
flavors = [
"latte"
"frappe"
"macchiato"
"mocha"
];

accent = types.enum [
accents = [
"blue"
"flamingo"
"green"
Expand All @@ -56,6 +56,12 @@ lib.makeExtensible (ctp: {
];
};

types = {
flavor = types.enum ctp.consts.flavors;

accent = types.enum ctp.consts.accents;
};

/**
Capitalize the first letter in a string
Expand Down
1 change: 1 addition & 0 deletions modules/nixos/all-modules.nix
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[
./fcitx5.nix
./gitea.nix
./grub.nix
./plymouth.nix
./sddm.nix
Expand Down
81 changes: 81 additions & 0 deletions modules/nixos/gitea.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
{ catppuccinLib }:
{
lib,
config,
...
}:
let
inherit (config.catppuccin) sources;

supportedForges = [
"gitea"
"forgejo"
];

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"
];
};

generateConfig =
forge:
let
cfg = config.catppuccin.${forge};
in
lib.mkIf cfg.enable {
systemd.services.${forge}.preStart =
let
inherit (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 ${sources.gitea} ${baseDir}/css
'';

services.${forge}.settings.ui = {
DEFAULT_THEME = "catppuccin-${cfg.flavor}-${cfg.accent}";
THEMES = builtins.concatStringsSep "," (
builtinThemes.${forge}
++ (lib.mapCartesianProduct ({ flavors, accents }: "catppuccin-${flavors}-${accents}") {
inherit (catppuccinLib.consts) flavors accents;
})
);
};
};
in
{
options.catppuccin = lib.genAttrs supportedForges (
name:
catppuccinLib.mkCatppuccinOption {
inherit name;
accentSupport = true;
}
);

config = lib.mkMerge (map generateConfig supportedForges);
}
1 change: 1 addition & 0 deletions modules/tests/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ testers.runNixOSTest {
package = pkgs.kdePackages.sddm; # our module/the upstream port requires the qt6 version
};
xserver.enable = true; # required for sddm
gitea.enable = true;
};

console.enable = true;
Expand Down
23 changes: 23 additions & 0 deletions pkgs/gitea/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ buildCatppuccinPort, fetchzip }:

buildCatppuccinPort (finalAttrs: {
pname = "gitea";
version = "0.4.1";

src = fetchzip {
url = "https://github.com/catppuccin/gitea/releases/download/v${finalAttrs.version}/catppuccin-gitea.tar.gz";
sha256 = "sha256-14XqO1ZhhPS7VDBSzqW55kh6n5cFZGZmvRCtMEh8JPI=";
stripRoot = false;
};

dontCatppuccinInstall = true;

installPhase = ''
runHook preInstall
mkdir -p $out
mv * $out
runHook postInstall
'';
})
2 changes: 1 addition & 1 deletion pkgs/sources.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@
"hash": "sha256-l6tztApzYpQ2/CiKuLBf8vI2imM6vPJuFdNDSEi7T/o=",
"rev": "7926c3d3e17d26b3779851a2255b95ee650bd928"
}
}
}

0 comments on commit 46c4804

Please sign in to comment.