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 Feb 3, 2025
1 parent 8eada39 commit d66a8e8
Show file tree
Hide file tree
Showing 6 changed files with 96 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
77 changes: 77 additions & 0 deletions modules/nixos/gitea.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
{ 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"
];
};
in
{
options.catppuccin = lib.genAttrs supportedForges (
name:
catppuccinLib.mkCatppuccinOption {
inherit name;
accentSupport = true;
}
);

config = lib.mkMerge (
map (
forge:
let
cfg = config.catppuccin.${forge};

inherit (config.services.${forge}) customDir;
themeDir =
if lib.versionAtLeast config.services.${forge}.package.version "1.21.0" then
"${customDir}/public/assets/css"
else
"${customDir}/public/css";
in
lib.mkIf cfg.enable {
systemd.tmpfiles.settings."10-catppuccin-${forge}-theme".${themeDir}."L+" = {
argument = themeDir;
};

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;
})
);
};
}
) supportedForges
);
}
2 changes: 2 additions & 0 deletions modules/tests/nixos.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ testers.runNixOSTest {
enable = true;
package = pkgs.kdePackages.sddm; # our module/the upstream port requires the qt6 version
};
forgejo.enable = true;
gitea.enable = true;
xserver.enable = true; # required for sddm
};

Expand Down
6 changes: 6 additions & 0 deletions pkgs/gitea/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ fetchzip }:
fetchzip {
url = "https://github.com/catppuccin/gitea/releases/download/v0.4.1/catppuccin-gitea.tar.gz";
hash = "sha256-14XqO1ZhhPS7VDBSzqW55kh6n5cFZGZmvRCtMEh8JPI=";
stripRoot = false;
}
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 d66a8e8

Please sign in to comment.