Forgejo: Difference between revisions
link to manual |
Add way to create/ensure users without wizard/webpage |
||
Line 102: | Line 102: | ||
} | } | ||
</syntaxhighlight> | </syntaxhighlight> | ||
== Ensure users == | |||
Using the following snippet, you can ensure users: | |||
<syntaxhighlight lang="nixos"> | |||
systemd.services.forgejo.preStart = '' | |||
create="${lib.getExe config.services.forgejo.package} admin user create" | |||
$create --admin --email "you@example.com" --username you --password "`cat ${config.sops.secrets.forgejo.path}`" &>/dev/null || true | |||
''; | |||
</syntaxhighlight> | |||
You may remove the <code>--admin</code> flag to create only a regular user. The <code>&>/dev/null || true</code> is necessary, so 1. The code snippet doesn't write to the log, 2. 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:Web Applications]] | ||
[[Category:Server]] | [[Category:Server]] | ||
[[Category:NixOS Manual]] | [[Category:NixOS Manual]] |