1# Forgejo {#module-forgejo}
2
3Forgejo is a soft-fork of gitea, with strong community focus, as well
4as on self-hosting and federation. [Codeberg](https://codeberg.org) is
5deployed from it.
6
7See [upstream docs](https://forgejo.org/docs/latest/).
8
9The method of choice for running forgejo is using [`services.forgejo`](#opt-services.forgejo.enable).
10
11::: {.warning}
12Running forgejo using `services.gitea.package = pkgs.forgejo` is no longer
13recommended.
14If you experience issues with your instance using `services.gitea`,
15**DO NOT** report them to the `services.gitea` module maintainers.
16**DO** report them to the `services.forgejo` module maintainers instead.
17:::
18
19## Migration from Gitea {#module-forgejo-migration-gitea}
20
21::: {.note}
22Migrating is, while not strictly necessary at this point, highly recommended.
23Both modules and projects are likely to divide further with each release.
24Which might lead to an even more involved migration.
25:::
26
27### Full-Migration {#module-forgejo-migration-gitea-default}
28
29This will migrate the state directory (data), rename and chown the database and
30delete the gitea user.
31
32::: {.note}
33This will also change the git remote ssh-url user from `gitea@` to `forgejo@`,
34when using the host's openssh server (default) instead of the integrated one.
35:::
36
37Instructions for PostgreSQL (default). Adapt accordingly for other databases:
38
39```sh
40systemctl stop gitea
41mv /var/lib/gitea /var/lib/forgejo
42runuser -u postgres -- psql -c '
43 ALTER USER gitea RENAME TO forgejo;
44 ALTER DATABASE gitea RENAME TO forgejo;
45'
46nixos-rebuild switch
47systemctl stop forgejo
48chown -R forgejo:forgejo /var/lib/forgejo
49systemctl restart forgejo
50```
51
52### Alternatively, keeping the gitea user {#module-forgejo-migration-gitea-impersonate}
53
54Alternatively, instead of renaming the database, copying the state folder and
55changing the user, the forgejo module can be set up to re-use the old storage
56locations and database, instead of having to copy or rename them.
57Make sure to disable `services.gitea`, when doing this.
58
59```nix
60services.gitea.enable = false;
61
62services.forgejo = {
63 enable = true;
64 user = "gitea";
65 group = "gitea";
66 stateDir = "/var/lib/gitea";
67 database.name = "gitea";
68 database.user = "gitea";
69};
70
71users.users.gitea = {
72 home = "/var/lib/gitea";
73 useDefaultShell = true;
74 group = "gitea";
75 isSystemUser = true;
76};
77
78users.groups.gitea = {};
79```