Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nixos): add support for gitea/forgejo #179

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
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
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"
}
}
}
Loading