···231 overriden by anything else.</para>
232 </listitem>
23300000000234</itemizedlist>
235236
···231 overriden by anything else.</para>
232 </listitem>
233234+ <listitem>
235+ <para>Large parts of the <literal>services.gitlab</literal> module has been
236+ been rewritten. There are new configuration options available. The
237+ <literal>stateDir</literal> option was renamned to
238+ <literal>statePath</literal> and the <literal>satellitesDir</literal> option
239+ was removed. Please review the currently available options.</para>
240+ </listitem>
241+242</itemizedlist>
243244
···1+<chapter xmlns="http://docbook.org/ns/docbook"
2+ xmlns:xlink="http://www.w3.org/1999/xlink"
3+ xmlns:xi="http://www.w3.org/2001/XInclude"
4+ version="5.0"
5+ xml:id="module-services-gitlab">
6+7+<title>Gitlab</title>
8+9+<para>Gitlab is a feature-rich git hosting service.</para>
10+11+<section><title>Prerequisites</title>
12+13+<para>The gitlab service exposes only an Unix socket at
14+<literal>/run/gitlab/gitlab-workhorse.socket</literal>. You need to configure a
15+webserver to proxy HTTP requests to the socket.</para>
16+17+<para>For instance, this could be used for Nginx:
18+19+<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>
43+44+</section>
45+46+<section><title>Configuring</title>
47+48+<para>Gitlab depends on both PostgreSQL and Redis and will automatically enable
49+both services. In the case of PostgreSQL, a database and a role will be created.
50+</para>
51+52+<para>The default state dir is /var/gitlab/state. This is where all data like
53+the repositories and uploads will be stored.</para>
54+55+<para>A basic configuration could look like this:
56+57+<programlisting>
58+services.gitlab = {
59+ enable = true;
60+ databasePassword = "eXaMpl3";
61+ initialRootPassword = "UseNixOS!";
62+ https = true;
63+ host = "git.example.com";
64+ port = 443;
65+ user = "git";
66+ group = "git";
67+ extraConfig = {
68+ gitlab = {
69+ default_projects_features = { builds = false; };
70+ };
71+ };
72+};
73+</programlisting>
74+</para>
75+76+<para>Refer to <xref linkend="ch-options" /> for all available configuration
77+options for the <literal>services.gitlab</literal> module.</para>
78+79+</section>
80+81+<section><title>Maintenance</title>
82+83+<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>
87+88+<para>For instance, to backup a Gitlab instance:
89+90+<programlisting>
91+$ sudo -u git -H gitlab-runner exec rake gitlab:backup:create
92+</programlisting>
93+94+A list of all availabe rake tasks can be obtained by running:
95+96+<programlisting>
97+$ sudo -u git -H gitlab-runner exec rake -T
98+</programlisting>
99+</para>
100+101+</section>
102+103+</chapter>
···1+diff --git a/lib/gitlab_projects.rb b/lib/gitlab_projects.rb
2+index c1d175a..7f7fd2f 100644
3+--- a/lib/gitlab_projects.rb
4++++ b/lib/gitlab_projects.rb
5+@@ -5,7 +5,7 @@ require_relative 'gitlab_config'
6+ require_relative 'gitlab_logger'
7+8+ class GitlabProjects
9+- GLOBAL_HOOKS_DIRECTORY = File.join(ROOT_PATH, 'hooks')
10++ GLOBAL_HOOKS_DIRECTORY = ENV['GITLAB_SHELL_HOOKS_PATH'] || File.join(ROOT_PATH, 'hooks')
11+12+ # Project name is a directory name for repository with .git at the end
13+ # It may be namespaced or not. Like repo.git or gitlab/repo.git
···1diff --git a/config/environments/production.rb b/config/environments/production.rb
2-index 3316ece..c34dec0 100644
3--- a/config/environments/production.rb
4+++ b/config/environments/production.rb
5-@@ -67,10 +67,10 @@ Gitlab::Application.configure do
67 config.action_mailer.delivery_method = :sendmail
8 # Defaults to:
···18 config.action_mailer.raise_delivery_errors = true
1920diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
21-index 15930fc..bdb423c 100644
22--- a/config/gitlab.yml.example
23+++ b/config/gitlab.yml.example
24-@@ -29,8 +29,8 @@ production: &base
25- ## GitLab settings
26- gitlab:
27- ## Web server settings (note: host is the FQDN, do not include http://)
28-- host: localhost
29-- port: 80 # Set to 443 if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
30-+ host: <%= ENV['GITLAB_HOST'] || 'localhost' %>
31-+ port: <%= ENV['GITLAB_PORT'] || 80 %>
32- https: false # Set to true if using HTTPS, see installation.md#using-https for additional HTTPS configuration details
33-34- # Uncommment this line below if your ssh host is different from HTTP/HTTPS one
35-@@ -43,7 +43,7 @@ production: &base
36- # relative_url_root: /gitlab
37-38- # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
39-- # user: git
40-+ user: gitlab
41-42- ## Date & Time settings
43- # Uncomment and customize if you want to change the default time zone of GitLab application.
44-@@ -54,7 +54,7 @@ production: &base
45- # Uncomment and set to false if you need to disable email sending from GitLab (default: true)
46- # email_enabled: true
47- # Email address used in the "From" field in mails sent by GitLab
48-- email_from: example@example.com
49-+ email_from: <%= ENV['GITLAB_EMAIL_FROM'] %>
50- email_display_name: GitLab
51- email_reply_to: noreply@example.com
52-53-@@ -298,12 +298,12 @@ production: &base
54- # GitLab Satellites
55- satellites:
56- # Relative paths are relative to Rails.root (default: tmp/repo_satellites/)
57-- path: /home/git/gitlab-satellites/
58-+ path: <%= ENV['GITLAB_SATELLITES_PATH'] %>
59- timeout: 30
60-61- ## Backup settings
62- backup:
63-- path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
64-+ path: <%= ENV['GITLAB_BACKUP_PATH'] %>
65- # archive_permissions: 0640 # Permissions for the resulting backup.tar file (default: 0600)
66- # keep_time: 604800 # default: 0 (forever) (in seconds)
67- # pg_schema: public # default: nil, it means that all schemas will be backed up
68-@@ -322,15 +322,15 @@ production: &base
69-70- ## GitLab Shell settings
71- gitlab_shell:
72-- path: /home/git/gitlab-shell/
73-+ path: <%= ENV['GITLAB_SHELL_PATH'] %>
74-75- # REPOS_PATH MUST NOT BE A SYMLINK!!!
76-- repos_path: /home/git/repositories/
77-- hooks_path: /home/git/gitlab-shell/hooks/
78-+ repos_path: <%= ENV['GITLAB_REPOSITORIES_PATH'] %>
79-+ hooks_path: <%= ENV['GITLAB_SHELL_HOOKS_PATH'] %>
80-81- # File that contains the secret key for verifying access for gitlab-shell.
82- # Default is '.gitlab_shell_secret' relative to Rails.root (i.e. root of the GitLab app).
83-- # secret_file: /home/git/gitlab/.gitlab_shell_secret
84-+ secret_file: <%= ENV['GITLAB_SHELL_SECRET_PATH'] %>
85-86- # Git over HTTP
87- upload_pack: true
88-@@ -343,7 +343,7 @@ production: &base
89 # CAUTION!
90 # Use the default values unless you really know what you are doing
91 git:
···94 # The next value is the maximum memory size grit can use
95 # Given in number of bytes per git object (e.g. a commit)
96 # This value can be increased if you have very large commits
97-@@ -388,7 +388,7 @@ test:
98- gravatar:
99- enabled: true
100- gitlab:
101-- host: localhost
102-+ host: <%= ENV['GITLAB_HOST'] %>
103- port: 80
104105- # When you run tests we clone and setup gitlab-shell
106-diff --git a/lib/gitlab/app_logger.rb b/lib/gitlab/app_logger.rb
107-index dddcb25..d61f10a 100644
108---- a/lib/gitlab/app_logger.rb
109-+++ b/lib/gitlab/app_logger.rb
110-@@ -1,7 +1,7 @@
111- module Gitlab
112- class AppLogger < Gitlab::Logger
113- def self.file_name_noext
114-- 'application'
115-+ ENV["GITLAB_APPLICATION_LOG_PATH"]
00000000000000000000116 end
000000000117118- def format_message(severity, timestamp, progname, msg)
0000000000000000000000000000
···1diff --git a/config/environments/production.rb b/config/environments/production.rb
2+index 9095266..694a4c5 100644
3--- a/config/environments/production.rb
4+++ b/config/environments/production.rb
5+@@ -67,10 +67,10 @@ Rails.application.configure do
67 config.action_mailer.delivery_method = :sendmail
8 # Defaults to:
···18 config.action_mailer.raise_delivery_errors = true
1920diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
21+index 05f127d..6a4ae68 100644
22--- a/config/gitlab.yml.example
23+++ b/config/gitlab.yml.example
24+@@ -423,7 +423,7 @@ production: &base
000000000000000000000000000000000000000000000000000000000000000025 # CAUTION!
26 # Use the default values unless you really know what you are doing
27 git:
···30 # The next value is the maximum memory size grit can use
31 # Given in number of bytes per git object (e.g. a commit)
32 # This value can be increased if you have very large commits
33+diff --git a/lib/gitlab/logger.rb b/lib/gitlab/logger.rb
34+index 59b2114..4f4a39a 100644
35+--- a/lib/gitlab/logger.rb
36++++ b/lib/gitlab/logger.rb
37+@@ -13,20 +13,20 @@ module Gitlab
38+ end
03940+ def self.read_latest
41+- path = Rails.root.join("log", file_name)
42++ path = File.join(ENV["GITLAB_LOG_PATH"], file_name)
43+ self.build unless File.exist?(path)
44+ tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
45+ tail_output.split("\n")
46+ end
47+48+ def self.read_latest_for(filename)
49+- path = Rails.root.join("log", filename)
50++ path = File.join(ENV["GITLAB_LOG_PATH"], filename)
51+ tail_output, _ = Gitlab::Popen.popen(%W(tail -n 2000 #{path}))
52+ tail_output.split("\n")
53+ end
54+55+ def self.build
56+- new(Rails.root.join("log", file_name))
57++ new(File.join(ENV["GITLAB_LOG_PATH"], file_name))
58+ end
59+ end
60+ end
61+diff --git a/lib/gitlab/uploads_transfer.rb b/lib/gitlab/uploads_transfer.rb
62+index be8fcc7..7642d74 100644
63+--- a/lib/gitlab/uploads_transfer.rb
64++++ b/lib/gitlab/uploads_transfer.rb
65+@@ -29,7 +29,7 @@ module Gitlab
66+ end
67+68+ def root_dir
69+- File.join(Rails.root, "public", "uploads")
70++ ENV['GITLAB_UPLOADS_PATH'] || File.join(Rails.root, "public", "uploads")
71 end
72+ end
73+ end
74+diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
75+index d59872d..0b8007f 100644
76+--- a/lib/tasks/gitlab/check.rake
77++++ b/lib/tasks/gitlab/check.rake
78+@@ -223,7 +223,7 @@ namespace :gitlab do
79+ def check_log_writable
80+ print "Log directory writable? ... "
8182+- log_path = Rails.root.join("log")
83++ log_path = ENV["GITLAB_LOG_PATH"]
84+85+ if File.writable?(log_path)
86+ puts "yes".green
87+@@ -263,10 +263,12 @@ namespace :gitlab do
88+ def check_uploads
89+ print "Uploads directory setup correctly? ... "
90+91+- unless File.directory?(Rails.root.join('public/uploads'))
92++ uploads_dir = ENV['GITLAB_UPLOADS_PATH'] || Rails.root.join('public/uploads')
93++
94++ unless File.directory?(uploads_dir)
95+ puts "no".red
96+ try_fixing_it(
97+- "sudo -u #{gitlab_user} mkdir #{Rails.root}/public/uploads"
98++ "sudo -u #{gitlab_user} mkdir #{uploads_dir}"
99+ )
100+ for_more_information(
101+ see_installation_guide_section "GitLab"
102+@@ -275,7 +277,7 @@ namespace :gitlab do
103+ return
104+ end
105+106+- upload_path = File.realpath(Rails.root.join('public/uploads'))
107++ upload_path = File.realpath(Rails.root.join(uploads_dir))
108+ upload_path_tmp = File.join(upload_path, 'tmp')
109+110+ if File.stat(upload_path).mode == 040700