Gitlab
Gitlab is a feature-rich git hosting service.
Prerequisites
The gitlab service exposes only an Unix socket at
/run/gitlab/gitlab-workhorse.socket. You need to configure a
webserver to proxy HTTP requests to the socket.
For instance, the following configuration could be used to use nginx as
frontend proxy:
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
virtualHosts."git.example.com" = {
enableACME = true;
forceSSL = true;
locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
};
};
'';
Configuring
Gitlab depends on both PostgreSQL and Redis and will automatically enable
both services. In the case of PostgreSQL, a database and a role will be created.
The default state dir is /var/gitlab/state. This is where
all data like the repositories and uploads will be stored.
A basic configuration with some custom settings could look like this:
services.gitlab = {
enable = true;
databasePassword = "eXaMpl3";
initialRootPassword = "UseNixOS!";
https = true;
host = "git.example.com";
port = 443;
user = "git";
group = "git";
smtp = {
enable = true;
address = "localhost";
port = 25;
};
secrets.db_key_base = "ei3eeP1ohsh0uu3ad4YeeMeeheengah3AiZee2ohl4Ooj5mie4Ohl0vishoghaes";
extraConfig = {
gitlab = {
email_from = "gitlab-no-reply@example.com";
email_display_name = "Example GitLab";
email_reply_to = "gitlab-no-reply@example.com";
default_projects_features = { builds = false; };
};
};
};
If you're setting up a new Gitlab instance, generate a new
db_key_base secret to encrypt sensible data in the
database. If you're restoring an existing Gitlab instance, you must
specify the db_key_base secret from
config/secrets.yml in your Gitlab state folder.
Refer to for all available configuration
options for the services.gitlab module.
Maintenance
You can run Gitlab's rake tasks with gitlab-rake
which will be available on the system when gitlab is enabled. You will
have to run the command as the user that you configured to run gitlab
with.
For example, to backup a Gitlab instance:
$ sudo -u git -H gitlab-rake gitlab:backup:create
A list of all availabe rake tasks can be obtained by running:
$ sudo -u git -H gitlab-rake -T