about summary refs log tree commit diff
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2021-02-16 12:08:59 +0100
committertalyz <kim.lindberger@gmail.com>2021-02-24 18:31:24 +0100
commit2ec397ff9fc2b384591d27878459f339c34e5485 (patch)
tree8d6d8179d0f0671baa508a2ba806832a262299c8
parentcc8ad48f0b62ef8bf6b538de76c1d1098fd0e199 (diff)
nixos/gitlab: Clean up the config dir more thoroughly
This removes all the subdirectories in `config` on start.

From one version of GitLab to the next, the files in the `config`
directory changes. Since we're only overwriting the existing files
with ones from the repo, cruft sometimes gets left behind,
occationally causing issues.

Ideally, all configuration put in the `config` directory is declared
by NixOS options and we could just remove the whole directory on
start, but I'm not sure if that's the case. It would also require a
little bit of additional rework and testing. The subdirectories,
however, should seldom contain user configuration and the ones that
frequently does, `initializers`, is already removed on start.
-rw-r--r--nixos/modules/services/misc/gitlab.nix9
1 files changed, 4 insertions, 5 deletions
diff --git a/nixos/modules/services/misc/gitlab.nix b/nixos/modules/services/misc/gitlab.nix
index 61faeab7d3212..4086a11ce873e 100644
--- a/nixos/modules/services/misc/gitlab.nix
+++ b/nixos/modules/services/misc/gitlab.nix
@@ -703,7 +703,6 @@ in {
       "d ${cfg.statePath} 0750 ${cfg.user} ${cfg.group} -"
       "d ${cfg.statePath}/builds 0750 ${cfg.user} ${cfg.group} -"
       "d ${cfg.statePath}/config 0750 ${cfg.user} ${cfg.group} -"
-      "d ${cfg.statePath}/config/initializers 0750 ${cfg.user} ${cfg.group} -"
       "d ${cfg.statePath}/db 0750 ${cfg.user} ${cfg.group} -"
       "d ${cfg.statePath}/log 0750 ${cfg.user} ${cfg.group} -"
       "d ${cfg.statePath}/repositories 2770 ${cfg.user} ${cfg.group} -"
@@ -879,10 +878,12 @@ in {
           preStart = ''
             set -eu
 
+            umask u=rwx,g=rx,o=
+
             cp -f ${cfg.packages.gitlab}/share/gitlab/VERSION ${cfg.statePath}/VERSION
             rm -rf ${cfg.statePath}/db/*
-            rm -rf ${cfg.statePath}/config/initializers/*
             rm -f ${cfg.statePath}/lib
+            find '${cfg.statePath}/config/' -maxdepth 1 -mindepth 1 -type d -execdir rm -rf {} \;
             cp -rf --no-preserve=mode ${cfg.packages.gitlab}/share/gitlab/config.dist/* ${cfg.statePath}/config
             cp -rf --no-preserve=mode ${cfg.packages.gitlab}/share/gitlab/db/* ${cfg.statePath}/db
             ln -sf ${extraGitlabRb} ${cfg.statePath}/config/initializers/extra-gitlab.rb
@@ -929,9 +930,7 @@ in {
                   "${cfg.statePath}/config/gitlab.yml"
               }
 
-              if [[ -h '${cfg.statePath}/config/secrets.yml' ]]; then
-                rm '${cfg.statePath}/config/secrets.yml'
-              fi
+              rm -f '${cfg.statePath}/config/secrets.yml'
 
               export secret="$(<'${cfg.secrets.secretFile}')"
               export db="$(<'${cfg.secrets.dbFile}')"