Skip to content

Commit

Permalink
nixos/gitlab: fixes
Browse files Browse the repository at this point in the history
- fix timezone data not found
- fix module, add simple test
- allow to set port
  • Loading branch information
offlinehacker committed Dec 12, 2014
1 parent 59995e1 commit 13e5878
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 11 deletions.
28 changes: 19 additions & 9 deletions nixos/modules/services/misc/gitlab.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ let
'';
gitlabShellYml = ''
user: gitlab
gitlab_url: "http://localhost:8080/"
gitlab_url: "http://${cfg.host}:${toString cfg.port}/"
http_settings:
self_signed_cert: false
repos_path: "${cfg.stateDir}/repositories"
Expand Down Expand Up @@ -57,6 +57,7 @@ let
--set GITLAB_SHELL_CONFIG_PATH "${cfg.stateDir}/shell/config.yml"\
--set GITLAB_SHELL_SECRET_PATH "${cfg.stateDir}/config/gitlab_shell_secret"\
--set GITLAB_HOST "${cfg.host}"\
--set GITLAB_PORT "${toString cfg.port}"\
--set GITLAB_BACKUP_PATH"${cfg.backupPath}"\
--set RAILS_ENV "production"
'';
Expand All @@ -77,43 +78,43 @@ in {
satelliteDir = mkOption {
type = types.str;
default = "/var/gitlab/git-satellites";
description = "Directory to store checked out git trees requires for operation.";
description = "Gitlab directory to store checked out git trees requires for operation.";
};

stateDir = mkOption {
type = types.str;
default = "/var/gitlab/state";
description = "The state directory, logs are stored here.";
description = "Gitlab state directory, logs are stored here.";
};

backupPath = mkOption {
type = types.str;
default = cfg.stateDir + "/backup";
description = "Path for backups.";
description = "Gitlab path for backups.";
};

databaseHost = mkOption {
type = types.str;
default = "127.0.0.1";
description = "Database hostname";
description = "Gitlab database hostname.";
};

databasePassword = mkOption {
type = types.str;
default = "";
description = "Database user password";
description = "Gitlab database user password.";
};

databaseName = mkOption {
type = types.str;
default = "gitlab";
description = "Database name";
description = "Gitlab database name.";
};

databaseUsername = mkOption {
type = types.str;
default = "gitlab";
description = "Database user";
description = "Gitlab database user.";
};

emailFrom = mkOption {
Expand All @@ -125,7 +126,13 @@ in {
host = mkOption {
type = types.str;
default = config.networking.hostName;
description = "The gitlab host name. Used e.g. for copy-paste URLs.";
description = "Gitlab host name. Used e.g. for copy-paste URLs.";
};

port = mkOption {
type = types.int;
default = 8080;
description = "Gitlab server listening port.";
};
};
};
Expand All @@ -144,6 +151,7 @@ in {
services.redis.enable = mkDefault true;
# We use postgres as the main data store.
services.postgresql.enable = mkDefault true;
services.postgresql.package = mkDefault pkgs.postgresql;
# Use postfix to send out mails.
services.postfix.enable = mkDefault true;

Expand Down Expand Up @@ -176,6 +184,7 @@ in {
environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml";
environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret";
environment.GITLAB_HOST = "${cfg.host}";
environment.GITLAB_PORT = "${toString cfg.port}";
environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}";
environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}";
environment.RAILS_ENV = "production";
Expand Down Expand Up @@ -209,6 +218,7 @@ in {
environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile";
environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}";
environment.GITLAB_HOST = "${cfg.host}";
environment.GITLAB_PORT = "${toString cfg.port}";
environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}";
environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}";
environment.RAILS_ENV = "production";
Expand Down
19 changes: 19 additions & 0 deletions nixos/tests/gitlab.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# This test runs gitlab and checks if it works

import ./make-test.nix {
name = "gitlab";

nodes = {
gitlab = { config, pkgs, ... }: {
virtualisation.memorySize = 768;
services.gitlab.enable = true;
services.gitlab.databasePassword = "gitlab";
};
};

testScript = ''
$gitlab->start();
$gitlab->waitForUnit("gitlab.service");
$gitlab->waitUntilSucceeds("curl http://localhost:8080");
'';
}
6 changes: 5 additions & 1 deletion pkgs/applications/version-management/gitlab/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ 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 }:
{ 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 }:

let
gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix);
Expand Down Expand Up @@ -61,6 +61,10 @@ in stdenv.mkDerivation rec {
# See https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide:
bundle install -j4 --verbose --local --deployment --without development test mysql
# Fix timezone data directory
substituteInPlace $out/share/gitlab/vendor/bundle/ruby/*/gems/tzinfo-*/lib/tzinfo/zoneinfo_data_source.rb \
--replace "/etc/zoneinfo" "${tzdata}/share/zoneinfo"
# For reasons I don't understand "bundle exec" ignores the
# RAILS_ENV causing tests to be executed that fail because we're
# not installing development and test gems above. Deleting the
Expand Down
4 changes: 3 additions & 1 deletion pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1271,7 +1271,9 @@ let

gifsicle = callPackage ../tools/graphics/gifsicle { };

gitlab = callPackage ../applications/version-management/gitlab { };
gitlab = callPackage ../applications/version-management/gitlab {
libiconv = libiconvOrLibc;
};

gitlab-shell = callPackage ../applications/version-management/gitlab-shell { };

Expand Down

0 comments on commit 13e5878

Please sign in to comment.