Forgejo: Difference between revisions
Add way to create/ensure users without wizard/webpage |
ensure users: add snippet for changing password of existing users |
||
| Line 106: | Line 106: | ||
Using the following snippet, you can ensure users: | Using the following snippet, you can ensure users: | ||
<syntaxhighlight lang="nixos"> | <syntaxhighlight lang="nixos"> | ||
sops.secrets.forgejo-admin-password.owner = "forgejo"; | |||
systemd.services.forgejo.preStart = '' | systemd.services.forgejo.preStart = '' | ||
admin="${lib.getExe config.services.forgejo.package} admin user" | |||
$create --admin --email " | $admin create --admin --email "root@localhost" --username admin --password "$(tr -d '\n' < $ | ||
{config.sops.secrets.forgejo-admin-password.path})" || true | |||
## uncomment this line to change an admin user which was already created | |||
# $admin change-password --username admin --password "$(tr -d '\n' < ${config.sops.secrets.f | |||
orgejo-admin-password.path})" || true | |||
''; | ''; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You may remove the <code>--admin</code> flag to create only a regular user. The <code> | 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. | Naturally, instead of sops, you may use any file or secret manager, as explained above. | ||