💾 Archived View for d.moonfire.us › blog › 2023 › 05 › 13 › nixos-gitea-forgejo-and-catppuccin captured on 2024-02-05 at 10:03:31. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-05-24)

-=-=-=-=-=-=-

NixOS, Gitea/Forgejo, and Catppuccin

Up a Level

I spent a couple hours today figuring out how to get the official Catppuccin[1] theme for Gitea[2] and Forgejo[3] integrated into my NixOS[4] environment. Originally, I had taken the user theme for Codeberg, tweaked and cleaned it up for my server, and then used that. But, I decided to go a little further and submitted a request to make it official. Someone then made an entirely new package and made it the official version[5]. After a little pouting, I decided that I'd rather have someone else maintain it so I can focus on other things.

1: /tags/catppuccin/

2: /tags/gitea/

3: /tags/forgejo/

4: /tags/nixos/

5: https://github.com/catppuccin/gitea

The first part was pulling it down. Originally, I thought I would grab it via the Nix flake, but that ended up being too difficult. After fumbling around, I came up with using `fetchzip` (which apparently does tarballs also) because the release files don't have a top-level directory (all the CSS are on the root).

inputs @ {
  config,
  pkgs,
  lib,
  ...
}: let
  theme = pkgs.fetchzip {
    url = "https://github.com/catppuccin/gitea/releases/download/v0.2.1/catppuccin-gitea.tar.gz";
    sha256 = "sha256-HqVLW58lKPn81p3gTSjzkACHSBbmqPqeobAlJMubb8Y=";
    stripRoot = false;
  };
in {}

From there, I needed to set it up. There aren't a lot of good ways (that I've found) with setting up data structures for services on NixOS, so I set everything up in the preStart of the service. The stanza below gets all the files into the right place.

systemd.services.gitea = {
  preStart = lib.mkAfter ''
    rm -rf ${config.services.gitea.stateDir}/custom/public
    mkdir -p ${config.services.gitea.stateDir}/custom/public
    ln -sf ${theme} ${config.services.gitea.stateDir}/custom/public/css
  '';
};

The last bit is to tell Gitea about the themes. I considered writing them all down, but there are quite a few of them (four basic types plus accents for each one), so I decided to dynamically build the list from the input.

services.gitea = {
  settings = {
    ui = {
      THEMES =
        builtins.concatStringsSep
        ","
        (["auto"]
          ++ (map (name: lib.removePrefix "theme-" (lib.removeSuffix ".css" name))
            (builtins.attrNames (builtins.readDir theme))));
      DEFAULT_THEME = "catppuccin-mocha-blue";
    };
  };
};

Thanks to ottidmes from the `#nix:nixos.org` matrix room for all the help.

In other news, I switched from Gitea to Forgejo on src.mfgames.com[6]. There wasn't a compelling reason other than I feel that I fit the philosophy more. I also disabled registrations on that server for now. If you want to send me an update, just use my contact page[7] and send directly.

6: https://src.mfgames.com/

7: /contact/

Metadata

Categories:

Development

Tags:

Catppuccin

Forgejo

Gitea

NixOS

Footer

Below are various useful links within this site and to related sites (not all have been converted over to Gemini).

Now

Contact

Biography

Bibliography

Support

Fiction

Fedran

Coding

The Moonfires

Categories

Tags

Privacy

Colophon

License

Mailing List

https://d.moonfire.us/blog/2023/05/13/nixos-gitea-forgejo-and-catppuccin/