about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/services/misc/forgejo.md
blob: 14b21933e6b09476ee058de03359ab48476f56cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# Forgejo {#module-forgejo}

Forgejo is a soft-fork of gitea, with strong community focus, as well
as on self-hosting and federation. [Codeberg](https://codeberg.org) is
deployed from it.

See [upstream docs](https://forgejo.org/docs/latest/).

The method of choice for running forgejo is using [`services.forgejo`](#opt-services.forgejo.enable).

::: {.warning}
Running forgejo using `services.gitea.package = pkgs.forgejo` is no longer
recommended.
If you experience issues with your instance using `services.gitea`,
**DO NOT** report them to the `services.gitea` module maintainers.
**DO** report them to the `services.forgejo` module maintainers instead.
:::

## Migration from Gitea {#module-forgejo-migration-gitea}

::: {.note}
Migrating is, while not strictly necessary at this point, highly recommended.
Both modules and projects are likely to diverge further with each release.
Which might lead to an even more involved migration.
:::

### Full-Migration {#module-forgejo-migration-gitea-default}

This will migrate the state directory (data), rename and chown the database and
delete the gitea user.

::: {.note}
This will also change the git remote ssh-url user from `gitea@` to `forgejo@`,
when using the host's openssh server (default) instead of the integrated one.
:::

Instructions for PostgreSQL (default). Adapt accordingly for other databases:

```sh
systemctl stop gitea
mv /var/lib/gitea /var/lib/forgejo
runuser -u postgres -- psql -c '
  ALTER USER gitea RENAME TO forgejo;
  ALTER DATABASE gitea RENAME TO forgejo;
'
nixos-rebuild switch
systemctl stop forgejo
chown -R forgejo:forgejo /var/lib/forgejo
systemctl restart forgejo
```

### Alternatively, keeping the gitea user {#module-forgejo-migration-gitea-impersonate}

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.

```nix
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 = {};
```