···11+# GitLab {#module-services-gitlab}
22+33+GitLab is a feature-rich git hosting service.
44+55+## Prerequisites {#module-services-gitlab-prerequisites}
66+77+The `gitlab` service exposes only an Unix socket at
88+`/run/gitlab/gitlab-workhorse.socket`. You need to
99+configure a webserver to proxy HTTP requests to the socket.
1010+1111+For instance, the following configuration could be used to use nginx as
1212+frontend proxy:
1313+```
1414+services.nginx = {
1515+ enable = true;
1616+ recommendedGzipSettings = true;
1717+ recommendedOptimisation = true;
1818+ recommendedProxySettings = true;
1919+ recommendedTlsSettings = true;
2020+ virtualHosts."git.example.com" = {
2121+ enableACME = true;
2222+ forceSSL = true;
2323+ locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
2424+ };
2525+};
2626+```
2727+2828+## Configuring {#module-services-gitlab-configuring}
2929+3030+GitLab depends on both PostgreSQL and Redis and will automatically enable
3131+both services. In the case of PostgreSQL, a database and a role will be
3232+created.
3333+3434+The default state dir is `/var/gitlab/state`. This is where
3535+all data like the repositories and uploads will be stored.
3636+3737+A basic configuration with some custom settings could look like this:
3838+```
3939+services.gitlab = {
4040+ enable = true;
4141+ databasePasswordFile = "/var/keys/gitlab/db_password";
4242+ initialRootPasswordFile = "/var/keys/gitlab/root_password";
4343+ https = true;
4444+ host = "git.example.com";
4545+ port = 443;
4646+ user = "git";
4747+ group = "git";
4848+ smtp = {
4949+ enable = true;
5050+ address = "localhost";
5151+ port = 25;
5252+ };
5353+ secrets = {
5454+ dbFile = "/var/keys/gitlab/db";
5555+ secretFile = "/var/keys/gitlab/secret";
5656+ otpFile = "/var/keys/gitlab/otp";
5757+ jwsFile = "/var/keys/gitlab/jws";
5858+ };
5959+ extraConfig = {
6060+ gitlab = {
6161+ email_from = "gitlab-no-reply@example.com";
6262+ email_display_name = "Example GitLab";
6363+ email_reply_to = "gitlab-no-reply@example.com";
6464+ default_projects_features = { builds = false; };
6565+ };
6666+ };
6767+};
6868+```
6969+7070+If you're setting up a new GitLab instance, generate new
7171+secrets. You for instance use
7272+`tr -dc A-Za-z0-9 < /dev/urandom | head -c 128 > /var/keys/gitlab/db` to
7373+generate a new db secret. Make sure the files can be read by, and
7474+only by, the user specified by
7575+[services.gitlab.user](#opt-services.gitlab.user). GitLab
7676+encrypts sensitive data stored in the database. If you're restoring
7777+an existing GitLab instance, you must specify the secrets secret
7878+from `config/secrets.yml` located in your GitLab
7979+state folder.
8080+8181+When `incoming_mail.enabled` is set to `true`
8282+in [extraConfig](#opt-services.gitlab.extraConfig) an additional
8383+service called `gitlab-mailroom` is enabled for fetching incoming mail.
8484+8585+Refer to [](#ch-options) for all available configuration
8686+options for the [services.gitlab](#opt-services.gitlab.enable) module.
8787+8888+## Maintenance {#module-services-gitlab-maintenance}
8989+9090+### Backups {#module-services-gitlab-maintenance-backups}
9191+9292+Backups can be configured with the options in
9393+[services.gitlab.backup](#opt-services.gitlab.backup.keepTime). Use
9494+the [services.gitlab.backup.startAt](#opt-services.gitlab.backup.startAt)
9595+option to configure regular backups.
9696+9797+To run a manual backup, start the `gitlab-backup` service:
9898+```ShellSession
9999+$ systemctl start gitlab-backup.service
100100+```
101101+102102+### Rake tasks {#module-services-gitlab-maintenance-rake}
103103+104104+You can run GitLab's rake tasks with `gitlab-rake`
105105+which will be available on the system when GitLab is enabled. You
106106+will have to run the command as the user that you configured to run
107107+GitLab with.
108108+109109+A list of all available rake tasks can be obtained by running:
110110+```ShellSession
111111+$ sudo -u git -H gitlab-rake -T
112112+```
+2
nixos/modules/services/misc/gitlab.nix
···1502150215031503 };
1504150415051505+ # Don't edit the docbook xml directly, edit the md and generate it:
15061506+ # `pandoc gitlab.md -t docbook --top-level-division=chapter --extract-media=media -f markdown-smart --lua-filter ../../../../doc/build-aux/pandoc-filters/myst-reader/roles.lua --lua-filter ../../../../doc/build-aux/pandoc-filters/docbook-writer/rst-roles.lua > gitlab.xml`
15051507 meta.doc = ./gitlab.xml;
1506150815071509}
+108-118
nixos/modules/services/misc/gitlab.xml
···11-<chapter xmlns="http://docbook.org/ns/docbook"
22- xmlns:xlink="http://www.w3.org/1999/xlink"
33- xmlns:xi="http://www.w3.org/2001/XInclude"
44- version="5.0"
55- xml:id="module-services-gitlab">
66- <title>GitLab</title>
77- <para>
88- GitLab is a feature-rich git hosting service.
99- </para>
1010- <section xml:id="module-services-gitlab-prerequisites">
1111- <title>Prerequisites</title>
1212-11+<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="module-services-gitlab">
22+ <title>GitLab</title>
133 <para>
1414- The <literal>gitlab</literal> service exposes only an Unix socket at
1515- <literal>/run/gitlab/gitlab-workhorse.socket</literal>. You need to
1616- configure a webserver to proxy HTTP requests to the socket.
44+ GitLab is a feature-rich git hosting service.
175 </para>
1818-1919- <para>
2020- For instance, the following configuration could be used to use nginx as
2121- frontend proxy:
2222-<programlisting>
66+ <section xml:id="module-services-gitlab-prerequisites">
77+ <title>Prerequisites</title>
88+ <para>
99+ The <literal>gitlab</literal> service exposes only an Unix socket
1010+ at <literal>/run/gitlab/gitlab-workhorse.socket</literal>. You
1111+ need to configure a webserver to proxy HTTP requests to the
1212+ socket.
1313+ </para>
1414+ <para>
1515+ For instance, the following configuration could be used to use
1616+ nginx as frontend proxy:
1717+ </para>
1818+ <programlisting>
2319services.nginx = {
2420 enable = true;
2521 recommendedGzipSettings = true;
2622 recommendedOptimisation = true;
2723 recommendedProxySettings = true;
2824 recommendedTlsSettings = true;
2929- virtualHosts."git.example.com" = {
2525+ virtualHosts."git.example.com" = {
3026 enableACME = true;
3127 forceSSL = true;
3232- locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
2828+ locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
3329 };
3430};
3531</programlisting>
3636- </para>
3737- </section>
3838- <section xml:id="module-services-gitlab-configuring">
3939- <title>Configuring</title>
4040-4141- <para>
4242- GitLab depends on both PostgreSQL and Redis and will automatically enable
4343- both services. In the case of PostgreSQL, a database and a role will be
4444- created.
4545- </para>
4646-4747- <para>
4848- The default state dir is <literal>/var/gitlab/state</literal>. This is where
4949- all data like the repositories and uploads will be stored.
5050- </para>
5151-5252- <para>
5353- A basic configuration with some custom settings could look like this:
5454-<programlisting>
3232+ </section>
3333+ <section xml:id="module-services-gitlab-configuring">
3434+ <title>Configuring</title>
3535+ <para>
3636+ GitLab depends on both PostgreSQL and Redis and will automatically
3737+ enable both services. In the case of PostgreSQL, a database and a
3838+ role will be created.
3939+ </para>
4040+ <para>
4141+ The default state dir is <literal>/var/gitlab/state</literal>.
4242+ This is where all data like the repositories and uploads will be
4343+ stored.
4444+ </para>
4545+ <para>
4646+ A basic configuration with some custom settings could look like
4747+ this:
4848+ </para>
4949+ <programlisting>
5550services.gitlab = {
5651 enable = true;
5757- databasePasswordFile = "/var/keys/gitlab/db_password";
5858- initialRootPasswordFile = "/var/keys/gitlab/root_password";
5252+ databasePasswordFile = "/var/keys/gitlab/db_password";
5353+ initialRootPasswordFile = "/var/keys/gitlab/root_password";
5954 https = true;
6060- host = "git.example.com";
5555+ host = "git.example.com";
6156 port = 443;
6262- user = "git";
6363- group = "git";
5757+ user = "git";
5858+ group = "git";
6459 smtp = {
6560 enable = true;
6666- address = "localhost";
6161+ address = "localhost";
6762 port = 25;
6863 };
6964 secrets = {
7070- dbFile = "/var/keys/gitlab/db";
7171- secretFile = "/var/keys/gitlab/secret";
7272- otpFile = "/var/keys/gitlab/otp";
7373- jwsFile = "/var/keys/gitlab/jws";
6565+ dbFile = "/var/keys/gitlab/db";
6666+ secretFile = "/var/keys/gitlab/secret";
6767+ otpFile = "/var/keys/gitlab/otp";
6868+ jwsFile = "/var/keys/gitlab/jws";
7469 };
7570 extraConfig = {
7671 gitlab = {
7777- email_from = "gitlab-no-reply@example.com";
7878- email_display_name = "Example GitLab";
7979- email_reply_to = "gitlab-no-reply@example.com";
7272+ email_from = "gitlab-no-reply@example.com";
7373+ email_display_name = "Example GitLab";
7474+ email_reply_to = "gitlab-no-reply@example.com";
8075 default_projects_features = { builds = false; };
8176 };
8277 };
8378};
8479</programlisting>
8585- </para>
8686-8787- <para>
8888- If you're setting up a new GitLab instance, generate new
8989- secrets. You for instance use <literal>tr -dc A-Za-z0-9 <
9090- /dev/urandom | head -c 128 > /var/keys/gitlab/db</literal> to
9191- generate a new db secret. Make sure the files can be read by, and
9292- only by, the user specified by <link
9393- linkend="opt-services.gitlab.user">services.gitlab.user</link>. GitLab
9494- encrypts sensitive data stored in the database. If you're restoring
9595- an existing GitLab instance, you must specify the secrets secret
9696- from <literal>config/secrets.yml</literal> located in your GitLab
9797- state folder.
9898- </para>
9999-100100- <para>
101101- When <literal>incoming_mail.enabled</literal> is set to <literal>true</literal>
102102- in <link linkend="opt-services.gitlab.extraConfig">extraConfig</link> an additional
103103- service called <literal>gitlab-mailroom</literal> is enabled for fetching incoming mail.
104104- </para>
105105-106106- <para>
107107- Refer to <xref linkend="ch-options" /> for all available configuration
108108- options for the
109109- <link linkend="opt-services.gitlab.enable">services.gitlab</link> module.
110110- </para>
111111- </section>
112112- <section xml:id="module-services-gitlab-maintenance">
113113- <title>Maintenance</title>
114114-115115- <section xml:id="module-services-gitlab-maintenance-backups">
116116- <title>Backups</title>
117117- <para>
118118- Backups can be configured with the options in <link
119119- linkend="opt-services.gitlab.backup.keepTime">services.gitlab.backup</link>. Use
120120- the <link
121121- linkend="opt-services.gitlab.backup.startAt">services.gitlab.backup.startAt</link>
122122- option to configure regular backups.
123123- </para>
124124-125125- <para>
126126- To run a manual backup, start the <literal>gitlab-backup</literal> service:
127127-<screen>
128128-<prompt>$ </prompt>systemctl start gitlab-backup.service
129129-</screen>
130130- </para>
8080+ <para>
8181+ If you're setting up a new GitLab instance, generate new secrets.
8282+ You for instance use
8383+ <literal>tr -dc A-Za-z0-9 < /dev/urandom | head -c 128 > /var/keys/gitlab/db</literal>
8484+ to generate a new db secret. Make sure the files can be read by,
8585+ and only by, the user specified by
8686+ <link linkend="opt-services.gitlab.user">services.gitlab.user</link>.
8787+ GitLab encrypts sensitive data stored in the database. If you're
8888+ restoring an existing GitLab instance, you must specify the
8989+ secrets secret from <literal>config/secrets.yml</literal> located
9090+ in your GitLab state folder.
9191+ </para>
9292+ <para>
9393+ When <literal>incoming_mail.enabled</literal> is set to
9494+ <literal>true</literal> in
9595+ <link linkend="opt-services.gitlab.extraConfig">extraConfig</link>
9696+ an additional service called <literal>gitlab-mailroom</literal> is
9797+ enabled for fetching incoming mail.
9898+ </para>
9999+ <para>
100100+ Refer to <xref linkend="ch-options"></xref> for all available
101101+ configuration options for the
102102+ <link linkend="opt-services.gitlab.enable">services.gitlab</link>
103103+ module.
104104+ </para>
131105 </section>
132132-133133- <section xml:id="module-services-gitlab-maintenance-rake">
134134- <title>Rake tasks</title>
135135-136136- <para>
137137- You can run GitLab's rake tasks with <literal>gitlab-rake</literal>
138138- which will be available on the system when GitLab is enabled. You
139139- will have to run the command as the user that you configured to run
140140- GitLab with.
141141- </para>
142142-143143- <para>
144144- A list of all available rake tasks can be obtained by running:
145145-<screen>
146146-<prompt>$ </prompt>sudo -u git -H gitlab-rake -T
147147-</screen>
148148- </para>
106106+ <section xml:id="module-services-gitlab-maintenance">
107107+ <title>Maintenance</title>
108108+ <section xml:id="module-services-gitlab-maintenance-backups">
109109+ <title>Backups</title>
110110+ <para>
111111+ Backups can be configured with the options in
112112+ <link linkend="opt-services.gitlab.backup.keepTime">services.gitlab.backup</link>.
113113+ Use the
114114+ <link linkend="opt-services.gitlab.backup.startAt">services.gitlab.backup.startAt</link>
115115+ option to configure regular backups.
116116+ </para>
117117+ <para>
118118+ To run a manual backup, start the
119119+ <literal>gitlab-backup</literal> service:
120120+ </para>
121121+ <programlisting>
122122+$ systemctl start gitlab-backup.service
123123+</programlisting>
124124+ </section>
125125+ <section xml:id="module-services-gitlab-maintenance-rake">
126126+ <title>Rake tasks</title>
127127+ <para>
128128+ You can run GitLab's rake tasks with
129129+ <literal>gitlab-rake</literal> which will be available on the
130130+ system when GitLab is enabled. You will have to run the command
131131+ as the user that you configured to run GitLab with.
132132+ </para>
133133+ <para>
134134+ A list of all available rake tasks can be obtained by running:
135135+ </para>
136136+ <programlisting>
137137+$ sudo -u git -H gitlab-rake -T
138138+</programlisting>
139139+ </section>
149140 </section>
150150- </section>
151141</chapter>