about summary refs log tree commit diff
path: root/nixos/modules/services/misc/gitlab.nix
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2017-09-02 23:16:02 +0200
committerRobin Gloster <mail@glob.in>2017-09-02 23:30:53 +0200
commitaaff3fa5f3605cb3a2f86ab3982b98a7afa60485 (patch)
tree16bc9d45ef4486547a86966e85601054ea70e9a5 /nixos/modules/services/misc/gitlab.nix
parent45605db3e02a5d6937bae65b3f24f44672390baa (diff)
downloadnixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar.gz
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar.bz2
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar.lz
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar.xz
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.tar.zst
nixlib-aaff3fa5f3605cb3a2f86ab3982b98a7afa60485.zip
gitlab module: fix postgres superUser
(cherry picked from commit edd8265c366186d62d870c23e2b2437ae4de4c0d)
Diffstat (limited to 'nixos/modules/services/misc/gitlab.nix')
-rw-r--r--nixos/modules/services/misc/gitlab.nix7
1 files changed, 4 insertions, 3 deletions
diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix
index 1b0333d38591..75bb366ca407 100644
--- a/nixos/modules/services/misc/gitlab.nix
+++ b/nixos/modules/services/misc/gitlab.nix
@@ -15,6 +15,7 @@ let
   gitlabSocket = "${cfg.statePath}/tmp/sockets/gitlab.socket";
   gitalySocket = "${cfg.statePath}/tmp/sockets/gitaly.socket";
   pathUrlQuote = url: replaceStrings ["/"] ["%2F"] url;
+  pgSuperUser = config.services.postgresql.superUser;
 
   databaseYml = ''
     production:
@@ -583,14 +584,14 @@ in {
 
         if [ "${cfg.databaseHost}" = "127.0.0.1" ]; then
           if ! test -e "${cfg.statePath}/db-created"; then
-            ${pkgs.sudo}/bin/sudo -u postgres psql postgres -c "CREATE ROLE ${cfg.databaseUsername} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.databasePassword}'"
-            ${pkgs.sudo}/bin/sudo -u postgres ${config.services.postgresql.package}/bin/createdb --owner ${cfg.databaseUsername} ${cfg.databaseName}
+            ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} psql postgres -c "CREATE ROLE ${cfg.databaseUsername} WITH LOGIN NOCREATEDB NOCREATEROLE ENCRYPTED PASSWORD '${cfg.databasePassword}'"
+            ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} ${config.services.postgresql.package}/bin/createdb --owner ${cfg.databaseUsername} ${cfg.databaseName}
             touch "${cfg.statePath}/db-created"
           fi
         fi
 
         # enable required pg_trgm extension for gitlab
-        ${pkgs.sudo}/bin/sudo -u postgres psql gitlab -c "CREATE EXTENSION IF NOT EXISTS pg_trgm"
+        ${pkgs.sudo}/bin/sudo -u ${pgSuperUser} psql gitlab -c "CREATE EXTENSION IF NOT EXISTS pg_trgm"
         # Always do the db migrations just to be sure the database is up-to-date
         ${gitlab-rake}/bin/gitlab-rake db:migrate RAILS_ENV=production