anchor.diff:          gnupg
         ];
         preStart = ''
  -        ${pkgs.sudo}/bin/sudo -u ${cfg.user} cp -f ${cfg.packages.gitlab}/share/gitlab/VERSION ${cfg.statePath}/VERSION
  -        ${pkgs.sudo}/bin/sudo -u ${cfg.user} rm -rf ${cfg.statePath}/db/*
  -        ${pkgs.sudo}/bin/sudo -u ${cfg.user} cp -rf --no-preserve=mode ${cfg.packages.gitlab}/share/gitlab/config.dist/* ${cfg.statePath}/config
  -        ${pkgs.sudo}/bin/sudo -u ${cfg.user} cp -rf --no-preserve=mode ${cfg.packages.gitlab}/share/gitlab/db/* ${cfg.statePath}/db
  -
  -        ${pkgs.sudo}/bin/sudo -u ${cfg.user} ${cfg.packages.gitlab-shell}/bin/install
  +        cp -f ${cfg.packages.gitlab}/share/gitlab/VERSION ${cfg.statePath}/VERSION
  +        rm -rf ${cfg.statePath}/db/*
  +        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
  +
  +        ${cfg.packages.gitlab-shell}/bin/install
   
           ${optionalString cfg.smtp.enable ''
  -          install -o ${cfg.user} -g ${cfg.group} -m u=rw ${smtpSettings} ${cfg.statePath}/config/initializers/smtp_settings.rb
  +          install -m u=rw ${smtpSettings} ${cfg.statePath}/config/initializers/smtp_settings.rb
             ${optionalString (cfg.smtp.passwordFile != null) ''
               smtp_password=$(<'${cfg.smtp.passwordFile}')
               ${pkgs.replace}/bin/replace-literal -e '@smtpPassword@' "$smtp_password" '${cfg.statePath}/config/initializers/smtp_settings.rb'
  
positive.code: 
      # Redis is required for the sidekiq queue runner.
      services.redis.enable = mkDefault true;
      # We use postgres as the main data store.
      services.postgresql.enable = mkDefault true;
      # Use postfix to send out mails.
      services.postfix.enable = mkDefault true;
  
  
negative.code:                                               db_key_base: $ENV.otp,
                                                openid_connect_signing_key: $ENV.jws}}' \
                              > '${cfg.statePath}/config/secrets.yml'
          )
  
          initial_root_password="$(<'${cfg.initialRootPasswordFile}')"
          ${gitlab-rake}/bin/gitlab-rake gitlab:db:configure GITLAB_ROOT_PASSWORD="$initial_root_password" \
                                                             GITLAB_ROOT_EMAIL='${cfg.initialRootEmail}'
  
          # We remove potentially broken links to old gitlab-shell versions
          rm -Rf ${cfg.statePath}/repositories/**/*.git/hooks
  
          ${pkgs.git}/bin/git config --global core.autocrlf "input"
        '';
  
        serviceConfig = {
          Type = "simple";
          User = cfg.user;
          Group = cfg.group;
  