nixos/gitlab: fixes

- fix timezone data not found
- fix module, add simple test
- allow to set port

+46 -11
+19 -9
nixos/modules/services/misc/gitlab.nix
··· 21 ''; 22 gitlabShellYml = '' 23 user: gitlab 24 - gitlab_url: "http://localhost:8080/" 25 http_settings: 26 self_signed_cert: false 27 repos_path: "${cfg.stateDir}/repositories" ··· 57 --set GITLAB_SHELL_CONFIG_PATH "${cfg.stateDir}/shell/config.yml"\ 58 --set GITLAB_SHELL_SECRET_PATH "${cfg.stateDir}/config/gitlab_shell_secret"\ 59 --set GITLAB_HOST "${cfg.host}"\ 60 --set GITLAB_BACKUP_PATH"${cfg.backupPath}"\ 61 --set RAILS_ENV "production" 62 ''; ··· 77 satelliteDir = mkOption { 78 type = types.str; 79 default = "/var/gitlab/git-satellites"; 80 - description = "Directory to store checked out git trees requires for operation."; 81 }; 82 83 stateDir = mkOption { 84 type = types.str; 85 default = "/var/gitlab/state"; 86 - description = "The state directory, logs are stored here."; 87 }; 88 89 backupPath = mkOption { 90 type = types.str; 91 default = cfg.stateDir + "/backup"; 92 - description = "Path for backups."; 93 }; 94 95 databaseHost = mkOption { 96 type = types.str; 97 default = "127.0.0.1"; 98 - description = "Database hostname"; 99 }; 100 101 databasePassword = mkOption { 102 type = types.str; 103 default = ""; 104 - description = "Database user password"; 105 }; 106 107 databaseName = mkOption { 108 type = types.str; 109 default = "gitlab"; 110 - description = "Database name"; 111 }; 112 113 databaseUsername = mkOption { 114 type = types.str; 115 default = "gitlab"; 116 - description = "Database user"; 117 }; 118 119 emailFrom = mkOption { ··· 125 host = mkOption { 126 type = types.str; 127 default = config.networking.hostName; 128 - description = "The gitlab host name. Used e.g. for copy-paste URLs."; 129 }; 130 }; 131 }; ··· 144 services.redis.enable = mkDefault true; 145 # We use postgres as the main data store. 146 services.postgresql.enable = mkDefault true; 147 # Use postfix to send out mails. 148 services.postfix.enable = mkDefault true; 149 ··· 176 environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml"; 177 environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret"; 178 environment.GITLAB_HOST = "${cfg.host}"; 179 environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; 180 environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; 181 environment.RAILS_ENV = "production"; ··· 209 environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile"; 210 environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}"; 211 environment.GITLAB_HOST = "${cfg.host}"; 212 environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; 213 environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; 214 environment.RAILS_ENV = "production";
··· 21 ''; 22 gitlabShellYml = '' 23 user: gitlab 24 + gitlab_url: "http://${cfg.host}:${toString cfg.port}/" 25 http_settings: 26 self_signed_cert: false 27 repos_path: "${cfg.stateDir}/repositories" ··· 57 --set GITLAB_SHELL_CONFIG_PATH "${cfg.stateDir}/shell/config.yml"\ 58 --set GITLAB_SHELL_SECRET_PATH "${cfg.stateDir}/config/gitlab_shell_secret"\ 59 --set GITLAB_HOST "${cfg.host}"\ 60 + --set GITLAB_PORT "${toString cfg.port}"\ 61 --set GITLAB_BACKUP_PATH"${cfg.backupPath}"\ 62 --set RAILS_ENV "production" 63 ''; ··· 78 satelliteDir = mkOption { 79 type = types.str; 80 default = "/var/gitlab/git-satellites"; 81 + description = "Gitlab directory to store checked out git trees requires for operation."; 82 }; 83 84 stateDir = mkOption { 85 type = types.str; 86 default = "/var/gitlab/state"; 87 + description = "Gitlab state directory, logs are stored here."; 88 }; 89 90 backupPath = mkOption { 91 type = types.str; 92 default = cfg.stateDir + "/backup"; 93 + description = "Gitlab path for backups."; 94 }; 95 96 databaseHost = mkOption { 97 type = types.str; 98 default = "127.0.0.1"; 99 + description = "Gitlab database hostname."; 100 }; 101 102 databasePassword = mkOption { 103 type = types.str; 104 default = ""; 105 + description = "Gitlab database user password."; 106 }; 107 108 databaseName = mkOption { 109 type = types.str; 110 default = "gitlab"; 111 + description = "Gitlab database name."; 112 }; 113 114 databaseUsername = mkOption { 115 type = types.str; 116 default = "gitlab"; 117 + description = "Gitlab database user."; 118 }; 119 120 emailFrom = mkOption { ··· 126 host = mkOption { 127 type = types.str; 128 default = config.networking.hostName; 129 + description = "Gitlab host name. Used e.g. for copy-paste URLs."; 130 + }; 131 + 132 + port = mkOption { 133 + type = types.int; 134 + default = 8080; 135 + description = "Gitlab server listening port."; 136 }; 137 }; 138 }; ··· 151 services.redis.enable = mkDefault true; 152 # We use postgres as the main data store. 153 services.postgresql.enable = mkDefault true; 154 + services.postgresql.package = mkDefault pkgs.postgresql; 155 # Use postfix to send out mails. 156 services.postfix.enable = mkDefault true; 157 ··· 184 environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml"; 185 environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret"; 186 environment.GITLAB_HOST = "${cfg.host}"; 187 + environment.GITLAB_PORT = "${toString cfg.port}"; 188 environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; 189 environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; 190 environment.RAILS_ENV = "production"; ··· 218 environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile"; 219 environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}"; 220 environment.GITLAB_HOST = "${cfg.host}"; 221 + environment.GITLAB_PORT = "${toString cfg.port}"; 222 environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; 223 environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; 224 environment.RAILS_ENV = "production";
+19
nixos/tests/gitlab.nix
···
··· 1 + # This test runs gitlab and checks if it works 2 + 3 + import ./make-test.nix { 4 + name = "gitlab"; 5 + 6 + nodes = { 7 + gitlab = { config, pkgs, ... }: { 8 + virtualisation.memorySize = 768; 9 + services.gitlab.enable = true; 10 + services.gitlab.databasePassword = "gitlab"; 11 + }; 12 + }; 13 + 14 + testScript = '' 15 + $gitlab->start(); 16 + $gitlab->waitForUnit("gitlab.service"); 17 + $gitlab->waitUntilSucceeds("curl http://localhost:8080"); 18 + ''; 19 + }
+5 -1
pkgs/applications/version-management/gitlab/default.nix
··· 1 - { stdenv, fetchurl, ruby, rubyLibs, libxslt, libxml2, pkgconfig, libffi, postgresql, libyaml, ncurses, curl, openssh, redis, zlib, icu, checkinstall, logrotate, docutils, cmake, git, gdbm, readline, unzip, gnumake, which }: 2 3 let 4 gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix); ··· 60 61 # See https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide: 62 bundle install -j4 --verbose --local --deployment --without development test mysql 63 64 # For reasons I don't understand "bundle exec" ignores the 65 # RAILS_ENV causing tests to be executed that fail because we're
··· 1 + { stdenv, fetchurl, ruby, rubyLibs, libiconv, libxslt, libxml2, pkgconfig, libffi, postgresql, libyaml, ncurses, curl, openssh, redis, zlib, icu, checkinstall, logrotate, docutils, cmake, git, gdbm, readline, unzip, gnumake, which, tzdata }: 2 3 let 4 gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix); ··· 60 61 # See https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide: 62 bundle install -j4 --verbose --local --deployment --without development test mysql 63 + 64 + # Fix timezone data directory 65 + substituteInPlace $out/share/gitlab/vendor/bundle/ruby/*/gems/tzinfo-*/lib/tzinfo/zoneinfo_data_source.rb \ 66 + --replace "/etc/zoneinfo" "${tzdata}/share/zoneinfo" 67 68 # For reasons I don't understand "bundle exec" ignores the 69 # RAILS_ENV causing tests to be executed that fail because we're
+3 -1
pkgs/top-level/all-packages.nix
··· 1271 1272 gifsicle = callPackage ../tools/graphics/gifsicle { }; 1273 1274 - gitlab = callPackage ../applications/version-management/gitlab { }; 1275 1276 gitlab-shell = callPackage ../applications/version-management/gitlab-shell { }; 1277
··· 1271 1272 gifsicle = callPackage ../tools/graphics/gifsicle { }; 1273 1274 + gitlab = callPackage ../applications/version-management/gitlab { 1275 + libiconv = libiconvOrLibc; 1276 + }; 1277 1278 gitlab-shell = callPackage ../applications/version-management/gitlab-shell { }; 1279