Forgejo: Difference between revisions
Create page with typical real-world usage example |
m Made code snippet more readable, modular, and informative. |
||
(5 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
[https://forgejo.org/ Forgejo] is a lightweight [[wikipedia:Software_forge|software forge]], with a highlight on being completely free software. It's a fork of [[Gitea]]. | [https://forgejo.org/ Forgejo] is a lightweight [[wikipedia:Software_forge|software forge]], with a highlight on being completely free software. It's a fork of [[Gitea]]. | ||
This article extends the documentation in the [https://nixos.org/manual/nixos/stable/#module-forgejo NixOS manual]. | |||
== Usage == | == Usage == | ||
Line 87: | Line 89: | ||
url = "https://git.example.com"; | url = "https://git.example.com"; | ||
# Obtaining the path to the runner token file may differ | # Obtaining the path to the runner token file may differ | ||
# tokenFile should be in format TOKEN=<secret>, since it's EnvironmentFile for systemd | |||
tokenFile = config.age.secrets.forgejo-runner-token.path; | tokenFile = config.age.secrets.forgejo-runner-token.path; | ||
labels = [ | labels = [ | ||
Line 100: | Line 103: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Ensure users == | |||
Using the following snippet, you can ensure users: | |||
<syntaxhighlight lang="nixos"> | |||
sops.secrets.forgejo-admin-password.owner = "forgejo"; | |||
systemd.services.forgejo.preStart = let | |||
adminCmd = "${lib.getExe cfg.package} admin user"; | |||
pwd = config.sops.secrets.forgejo-admin-password; | |||
user = "joe"; # Note, Forgejo doesn't allow creation of an account named "admin" | |||
in '' | |||
${adminCmd} create --admin --email "root@localhost" --username ${user} --password "$(tr -d '\n' < ${pwd.path})" || true | |||
## uncomment this line to change an admin user which was already created | |||
# ${adminCmd} change-password --username ${user} --password "$(tr -d '\n' < ${pwd.path})" || true | |||
''; | |||
</syntaxhighlight> | |||
You may remove the <code>--admin</code> flag to create only a regular user. The <code>|| true</code> is necessary, so the snippet does not fail if the user already exists. | |||
Naturally, instead of sops, you may use any file or secret manager, as explained above. | |||
[[Category:Web Applications]] | |||
[[Category:Server]] | |||
[[Category:NixOS Manual]] |