···42 </listitem>
4344 <listitem>
45- <para>Redis now binds to 127.0.0.1 only instead of listening to all network interfaces. This is the default
46 behavior of Redis 3.2</para>
0000047 </listitem>
4849</itemizedlist>
···42 </listitem>
4344 <listitem>
45+ <para>Redis now binds to 127.0.0.1 only instead of listening to all network interfaces. This is the default
46 behavior of Redis 3.2</para>
47+ </listitem>
48+49+ <listitem>
50+ <para>Gitlab's maintainence script gitlab-runner was removed and split up into the more clearer
51+ gitlab-run and gitlab-rake scripts because gitlab-runner is a component of Gitlab CI.</para>
52 </listitem>
5354</itemizedlist>
···57 issues = true;
58 merge_requests = true;
59 wiki = true;
60+ snippets = true;
61 builds = true;
62+ container_registry = true;
63 };
64 };
65+ repositories.storages.default = "${cfg.statePath}/repositories";
66+ artifacts.enabled = true;
67+ lfs.enabled = true;
68+ gravatar.enabled = true;
69+ cron_jobs = { };
70+ gitlab_ci.builds_path = "${cfg.statePath}/builds";
71+ ldap.enabled = false;
72+ omniauth.enabled = false;
73+ shared.path = "${cfg.statePath}/shared";
74+ backup.path = "${cfg.backupPath}";
000000000000000000075 gitlab_shell = {
76 path = "${cfg.packages.gitlab-shell}";
077 hooks_path = "${cfg.statePath}/shell/hooks";
78 secret_file = "${cfg.statePath}/config/gitlab_shell_secret";
79 upload_pack = true;
···106107 unicornConfig = builtins.readFile ./defaultUnicornConfig.rb;
108109+ gitlab-rake = pkgs.stdenv.mkDerivation rec {
110+ name = "gitlab-rake";
111+ buildInputs = [ cfg.packages.gitlab cfg.packages.gitlab.env pkgs.makeWrapper ];
112 phases = "installPhase fixupPhase";
113 buildPhase = "";
114 installPhase = ''
115 mkdir -p $out/bin
116+ makeWrapper ${cfg.packages.gitlab.env}/bin/bundle $out/bin/gitlab-bundle \
117+ ${concatStrings (mapAttrsToList (name: value: "--set ${name} '${value}' ") gitlabEnv)} \
118+ --set GITLAB_CONFIG_PATH '${cfg.statePath}/config' \
119+ --set PATH '${pkgs.nodejs}/bin:${pkgs.gzip}/bin:${config.services.postgresql.package}/bin:$PATH' \
120+ --set RAKEOPT '-f ${cfg.packages.gitlab}/share/gitlab/Rakefile' \
121+ --run 'cd ${cfg.packages.gitlab}/share/gitlab'
122+ makeWrapper $out/bin/gitlab-bundle $out/bin/gitlab-rake \
123+ --add-flags "exec rake"
124+ '';
125 };
126127+ smtpSettings = pkgs.writeText "gitlab-smtp-settings.rb" ''
128+ if Rails.env.production?
129+ Rails.application.config.action_mailer.delivery_method = :smtp
130+131+ ActionMailer::Base.delivery_method = :smtp
132+ ActionMailer::Base.smtp_settings = {
133+ address: "${cfg.smtp.address}",
134+ port: ${toString cfg.smtp.port},
135+ ${optionalString (cfg.smtp.username != null) ''user_name: "${cfg.smtp.username}",''}
136+ ${optionalString (cfg.smtp.password != null) ''password: "${cfg.smtp.password}",''}
137+ domain: "${cfg.smtp.domain}",
138+ ${optionalString (cfg.smtp.authentication != null) "authentication: :${cfg.smtp.authentication},"}
139+ enable_starttls_auto: ${toString cfg.smtp.enableStartTLSAuto},
140+ openssl_verify_mode: '${cfg.smtp.opensslVerifyMode}'
141+ }
142+ end
143+ '';
144+145in {
146147 options = {
···257 '';
258 };
259260+ smtp = {
261+ enable = mkOption {
262+ type = types.bool;
263+ default = false;
264+ description = "Enable gitlab mail delivery over SMTP.";
265+ };
266+267+ address = mkOption {
268+ type = types.str;
269+ default = "localhost";
270+ description = "Address of the SMTP server for Gitlab.";
271+ };
272+273+ port = mkOption {
274+ type = types.int;
275+ default = 465;
276+ description = "Port of the SMTP server for Gitlab.";
277+ };
278+279+ username = mkOption {
280+ type = types.nullOr types.str;
281+ default = null;
282+ description = "Username of the SMTP server for Gitlab.";
283+ };
284+285+ password = mkOption {
286+ type = types.nullOr types.str;
287+ default = null;
288+ description = "Password of the SMTP server for Gitlab.";
289+ };
290+291+ domain = mkOption {
292+ type = types.str;
293+ default = "localhost";
294+ description = "HELO domain to use for outgoing mail.";
295+ };
296+297+ authentication = mkOption {
298+ type = types.nullOr types.str;
299+ default = null;
300+ description = "Authentitcation type to use, see http://api.rubyonrails.org/classes/ActionMailer/Base.html";
301+ };
302+303+ enableStartTLSAuto = mkOption {
304+ type = types.bool;
305+ default = true;
306+ description = "Whether to try to use StartTLS.";
307+ };
308+309+ opensslVerifyMode = mkOption {
310+ type = types.str;
311+ default = "peer";
312+ description = "How OpenSSL checks the certificate, see http://api.rubyonrails.org/classes/ActionMailer/Base.html";
313+ };
314+ };
315+316 extraConfig = mkOption {
317 type = types.attrs;
318 default = {};
···333334 config = mkIf cfg.enable {
335336+ environment.systemPackages = [ pkgs.git gitlab-rake cfg.packages.gitlab-shell ];
337338 assertions = [
339 { assertion = cfg.databasePassword != "";
···366 systemd.services.gitlab-sidekiq = {
367 after = [ "network.target" "redis.service" ];
368 wantedBy = [ "multi-user.target" ];
369+ partOf = [ "gitlab.service" ];
370 environment = gitlabEnv;
371 path = with pkgs; [
372 config.services.postgresql.package
···381 Group = cfg.group;
382 TimeoutSec = "300";
383 WorkingDirectory = "${cfg.packages.gitlab}/share/gitlab";
384+ ExecStart="${cfg.packages.gitlab.env}/bin/bundle exec \"sidekiq -q post_receive -q mailers -q system_hook -q project_web_hook -q gitlab_shell -q common -q default -e production -P ${cfg.statePath}/tmp/sidekiq.pid\"";
385 };
386 };
387···456 chmod -R u+rwX,go-rwx+X ${gitlabEnv.HOME}/
457458 cp -rf ${cfg.packages.gitlab}/share/gitlab/config.dist/* ${cfg.statePath}/config
459+ ${optionalString cfg.smtp.enable ''
460+ ln -sf ${smtpSettings} ${cfg.statePath}/config/initializers/smtp_settings.rb
461+ ''}
462 ln -sf ${cfg.statePath}/config /run/gitlab/config
463 cp ${cfg.packages.gitlab}/share/gitlab/VERSION ${cfg.statePath}/VERSION
464···482 touch "${cfg.statePath}/db-created"
483484 # The gitlab:setup task is horribly broken somehow, these two tasks will do the same for setting up the initial database
485+ ${gitlab-rake}/bin/gitlab-rake db:migrate RAILS_ENV=production
486+ ${gitlab-rake}/bin/gitlab-rake db:seed_fu RAILS_ENV=production \
487 GITLAB_ROOT_PASSWORD="${cfg.initialRootPassword}" GITLAB_ROOT_EMAIL="${cfg.initialRootEmail}";
488 fi
489 fi
490491 # Always do the db migrations just to be sure the database is up-to-date
492+ ${gitlab-rake}/bin/gitlab-rake db:migrate RAILS_ENV=production
493494 # Change permissions in the last step because some of the
495 # intermediary scripts like to create directories as root.
···503 User = cfg.user;
504 Group = cfg.group;
505 TimeoutSec = "300";
506+ Restart = "on-failure";
507 WorkingDirectory = "${cfg.packages.gitlab}/share/gitlab";
508+ ExecStart = "${cfg.packages.gitlab.env}/bin/bundle exec \"unicorn -c ${cfg.statePath}/config/unicorn.rb -E production\"";
509 };
510511 };
+32-31
nixos/modules/services/misc/gitlab.xml
···14<literal>/run/gitlab/gitlab-workhorse.socket</literal>. You need to configure a
15webserver to proxy HTTP requests to the socket.</para>
1617-<para>For instance, this could be used for Nginx:
01819<programlisting>
20-services.nginx.httpConfig = ''
21- server {
22- server_name git.example.com;
23- listen 443 ssl spdy;
24- listen [::]:443 ssl spdy;
25-26- ssl_certificate /var/lib/acme/git.example.com/fullchain.pem;
27- ssl_certificate_key /var/lib/acme/git.example.com/key.pem;
28-29- location / {
30- proxy_http_version 1.1;
31- proxy_set_header Host $http_host;
32- proxy_set_header X-Real-IP $remote_addr;
33- proxy_set_header X-Forwarded-Ssl on;
34- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
35- proxy_set_header X-Forwarded-Proto $scheme;
36-37- proxy_pass http://unix:/run/gitlab/gitlab-workhorse.socket;
38- }
39- }
40'';
41</programlisting>
42</para>
···49both services. In the case of PostgreSQL, a database and a role will be created.
50</para>
5152-<para>The default state dir is /var/gitlab/state. This is where all data like
53-the repositories and uploads will be stored.</para>
5455-<para>A basic configuration could look like this:
5657<programlisting>
58services.gitlab = {
···64 port = 443;
65 user = "git";
66 group = "git";
0000067 extraConfig = {
68 gitlab = {
00069 default_projects_features = { builds = false; };
70 };
71 };
···8081<section><title>Maintenance</title>
8283-<para>You can run all Gitlab related commands like rake tasks with
84-<literal>gitlab-runner</literal> which will be available on the system
85-when gitlab is enabled. You will have to run the commands as the user that
86-you configured to run gitlab.</para>
8788-<para>For instance, to backup a Gitlab instance:
8990<programlisting>
91-$ sudo -u git -H gitlab-runner exec rake gitlab:backup:create
92</programlisting>
9394A list of all availabe rake tasks can be obtained by running:
9596<programlisting>
97-$ sudo -u git -H gitlab-runner exec rake -T
98</programlisting>
99</para>
100
···14<literal>/run/gitlab/gitlab-workhorse.socket</literal>. You need to configure a
15webserver to proxy HTTP requests to the socket.</para>
1617+<para>For instance, the following configuration could be used to use nginx as
18+ frontend proxy:
1920<programlisting>
21+ services.nginx = {
22+ enable = true;
23+ recommendedGzipSettings = true;
24+ recommendedOptimisation = true;
25+ recommendedProxySettings = true;
26+ recommendedTlsSettings = true;
27+ virtualHosts."git.example.com" = {
28+ enableACME = true;
29+ forceSSL = true;
30+ locations."/".proxyPass = "http://unix:/run/gitlab/gitlab-workhorse.socket";
31+ };
32+ };
0000000033'';
34</programlisting>
35</para>
···42both services. In the case of PostgreSQL, a database and a role will be created.
43</para>
4445+<para>The default state dir is <literal>/var/gitlab/state</literal>. This is where
46+all data like the repositories and uploads will be stored.</para>
4748+<para>A basic configuration with some custom settings could look like this:
4950<programlisting>
51services.gitlab = {
···57 port = 443;
58 user = "git";
59 group = "git";
60+ smtp = {
61+ enable = true;
62+ address = "localhost";
63+ port = 25;
64+ };
65 extraConfig = {
66 gitlab = {
67+ email_from = "gitlab-no-reply@example.com";
68+ email_display_name = "Example GitLab";
69+ email_reply_to = "gitlab-no-reply@example.com";
70 default_projects_features = { builds = false; };
71 };
72 };
···8182<section><title>Maintenance</title>
8384+<para>You can run Gitlab's rake tasks with <literal>gitlab-rake</literal>
85+which will be available on the system when gitlab is enabled. You will
86+have to run the command as the user that you configured to run gitlab
87+with.</para>
8889+<para>For example, to backup a Gitlab instance:
9091<programlisting>
92+$ sudo -u git -H gitlab-rake gitlab:backup:create
93</programlisting>
9495A list of all availabe rake tasks can be obtained by running:
9697<programlisting>
98+$ sudo -u git -H gitlab-rake -T
99</programlisting>
100</para>
101