Forgejo: Difference between revisions
m Added the comment for the tokenFile for forgejo-runner code block |
m Made code snippet more readable, modular, and informative. |
||
| Line 108: | Line 108: | ||
<syntaxhighlight lang="nixos"> | <syntaxhighlight lang="nixos"> | ||
sops.secrets.forgejo-admin-password.owner = "forgejo"; | sops.secrets.forgejo-admin-password.owner = "forgejo"; | ||
systemd.services.forgejo.preStart = | 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 | ## 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> | </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. | 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. | ||