Add gitlab and gitlab-shell.

I had to make several adjustments to make it work with nixos:

* Replace relative config file lookups with ENV variable.
* Modify gitlab-shell to not clear then environment when running
  pre-receive.
* Modify gitlab-shell to write some environment variables into
  the .authorized_keys file to make sure gitlab-shell reads the
  correct config file.

The current version requires the user to install the gitlab-shell
package into the systemPackages environment because
/run/current-system/sw/bin/gitlab-shell is hard-coded in the
.authorized_keys file.
@teh do you have any idea why gitlab startup is so super slow?
On Dec 16, 2014 11:57 AM, "teh" <notifications@github.com> wrote:

> In nixos/modules/services/misc/gitlab.nix
> <https://github.com/NixOS/nixpkgs/pull/4796#discussion-diff-21890128>:
>
> > +      wantedBy = [ "multi-user.target" ];
> > +      environment.HOME = "${cfg.stateDir}/home";
> > +      environment.UNICORN_PATH = "${cfg.stateDir}/";
> > +      environment.GITLAB_PATH = "${pkgs.gitlab}/share/gitlab/";
> > +      environment.GITLAB_APPLICATION_LOG_PATH = "${cfg.stateDir}/log/application.log";
> > +      environment.GITLAB_SATELLITES_PATH = "${cfg.stateDir}/satellites";
> > +      environment.GITLAB_SHELL_PATH = "${pkgs.gitlab-shell}";
> > +      environment.GITLAB_REPOSITORIES_PATH = "${cfg.stateDir}/repositories";
> > +      environment.GITLAB_SHELL_HOOKS_PATH = "${cfg.stateDir}/shell/hooks";
> > +      environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile";
> > +      environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}";
> > +      environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml";
> > +      environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret";
> > +      environment.GITLAB_HOST = "${cfg.host}";
> > +      environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}";
> > +      environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}";
>
> It's been a few weeks so my memory is already hazy but I think I couldn't
> get bundler to read the whole rails config directory from anywhere else
> other than the execution point (i.e. in a read-only nix-store path).
>
> I'd be super happy if someone knowledgeable would make this cleaner!
>
> I packaged sentry for our website and it's just so much nicer because it
> takes single config file on execution. None of the relative importing that
> rails seems to do:
> https://github.com/WeAreWizards/website/tree/master/sentry
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/NixOS/nixpkgs/pull/4796/files#r21890128>.
>