hosts/plover: refactor Gitea config

This commit is contained in:
Gabriel Arazas 2023-10-08 03:26:53 +08:00
parent c35b72352e
commit f489c50aa9
No known key found for this signature in database
GPG Key ID: ADE0C41DAB221FCC

View File

@ -140,26 +140,25 @@ in
# Setting up Gitea for PostgreSQL secure schema usage. # Setting up Gitea for PostgreSQL secure schema usage.
systemd.services.gitea = { systemd.services.gitea = {
path = [ config.services.postgresql.package ];
# Gitea service module will have to set up certain things first which is # Gitea service module will have to set up certain things first which is
# why we have to go first. # why we have to go first.
preStart = preStart =
let let
giteaBin = "${lib.getBin config.services.gitea.package}/bin/gitea"; gitea = lib.getExe' config.services.gitea.package "gitea";
giteaAdminUsername = lib.escapeShellArg "foodogsquared"; giteaAdminUsername = lib.escapeShellArg "foodogsquared";
psql = lib.getExe' config.services.postgresql.package "psql";
in in
lib.mkMerge [ lib.mkMerge [
(lib.mkBefore '' (lib.mkBefore ''
# Setting up the appropriate schema for PostgreSQL secure schema usage. # Setting up the appropriate schema for PostgreSQL secure schema usage.
psql -tAc "SELECT 1 FROM information_schema.schemata WHERE schema_name='${giteaDatabaseUser}';" \ ${psql} -tAc "SELECT 1 FROM information_schema.schemata WHERE schema_name='${giteaDatabaseUser}';" \
grep -q 1 || psql -tAc "CREATE SCHEMA IF NOT EXISTS AUTHORIZATION ${giteaDatabaseUser};" grep -q 1 || ${psql} -tAc "CREATE SCHEMA IF NOT EXISTS AUTHORIZATION ${giteaDatabaseUser};"
'') '')
(lib.mkAfter '' (lib.mkAfter ''
# Setting up the administrator account automated. # Setting up the administrator account automated.
${giteaBin} admin user list --admin | grep -q ${giteaAdminUsername} \ ${gitea} admin user list --admin | grep -q ${giteaAdminUsername} \
|| ${giteaBin} admin user create \ || ${gitea} admin user create \
--username ${giteaAdminUsername} --email foodogsquared@${config.networking.domain} \ --username ${giteaAdminUsername} --email foodogsquared@${config.networking.domain} \
--random-password --random-password-length 76 --admin --random-password --random-password-length 76 --admin
'') '')