Forgejo is a soft-fork of gitea, with strong community focus, as well as on self-hosting and federation. Codeberg is deployed from it.
See upstream docs.
The method of choice for running forgejo is using services.forgejo.
Migration from Gitea
In order to migrate, the version of Forgejo needs to be pinned to 10.0.x
before using the latest version. This means that nixpkgs commit
3bb45b041e7147e2fd2daf689e26a1f970a55d65
or earlier should be used.
To do this, temporarily add the following to your configuration.nix:
{ pkgs, ... }:let nixpkgs-forgejo-10 = import (pkgs.fetchFromGitHub { owner = "NixOS"; repo = "nixpkgs"; rev = "3bb45b041e7147e2fd2daf689e26a1f970a55d65"; hash = "sha256-8JL5NI9eUcGzzbR/ARkrG81WLwndoxqI650mA/4rUGI="; }) { };in{ services.forgejo.package = nixpkgs-forgejo-10.forgejo;}Full-Migration
This will migrate the state directory (data), rename and chown the database and delete the gitea user.
Instructions for PostgreSQL (default). Adapt accordingly for other databases:
systemctl stop giteamv /var/lib/gitea /var/lib/forgejorunuser -u postgres -- psql -c ' ALTER USER gitea RENAME TO forgejo; ALTER DATABASE gitea RENAME TO forgejo;'nixos-rebuild switchsystemctl stop forgejochown -R forgejo:forgejo /var/lib/forgejosystemctl restart forgejoAfterwards, the Forgejo version can be set back to a newer desired version.
Alternatively, keeping the gitea user
Alternatively, instead of renaming the database, copying the state folder and
changing the user, the forgejo module can be set up to re-use the old storage
locations and database, instead of having to copy or rename them.
Make sure to disable services.gitea, when doing this.
{ services.gitea.enable = false;
services.forgejo = { enable = true; user = "gitea"; group = "gitea"; stateDir = "/var/lib/gitea"; database.name = "gitea"; database.user = "gitea"; };
users.users.gitea = { home = "/var/lib/gitea"; useDefaultShell = true; group = "gitea"; isSystemUser = true; };
users.groups.gitea = { };}