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 5-10 minutes in tests
On Dec 16, 2014 12:38 PM, "teh" <notifications@github.com> wrote:

> In nixos/modules/services/misc/gitlab.nix
> <https://github.com/NixOS/nixpkgs/pull/4796#discussion-diff-21892023>:
>
> > +      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}";
>
> @offlinehacker <https://github.com/offlinehacker> can you quantify "super
> slow"? E.g. we had a digital-ocean instance with gitlab and it took ~30
> seconds to start on there. I think that counts as "normal" for gitlab.
>
> —
> Reply to this email directly or view it on GitHub
> <https://github.com/NixOS/nixpkgs/pull/4796/files#r21892023>.
>