nixos/gitlab: fixes

- fix timezone data not found
- fix module, add simple test
- allow to set port
This commit is contained in:
Jaka Hudoklin 2014-11-30 00:56:22 +01:00
parent 59995e168c
commit 13e58784bf
4 changed files with 46 additions and 11 deletions

View File

@ -21,7 +21,7 @@ let
''; '';
gitlabShellYml = '' gitlabShellYml = ''
user: gitlab user: gitlab
gitlab_url: "http://localhost:8080/" gitlab_url: "http://${cfg.host}:${toString cfg.port}/"
http_settings: http_settings:
self_signed_cert: false self_signed_cert: false
repos_path: "${cfg.stateDir}/repositories" repos_path: "${cfg.stateDir}/repositories"
@ -57,6 +57,7 @@ let
--set GITLAB_SHELL_CONFIG_PATH "${cfg.stateDir}/shell/config.yml"\ --set GITLAB_SHELL_CONFIG_PATH "${cfg.stateDir}/shell/config.yml"\
--set GITLAB_SHELL_SECRET_PATH "${cfg.stateDir}/config/gitlab_shell_secret"\ --set GITLAB_SHELL_SECRET_PATH "${cfg.stateDir}/config/gitlab_shell_secret"\
--set GITLAB_HOST "${cfg.host}"\ --set GITLAB_HOST "${cfg.host}"\
--set GITLAB_PORT "${toString cfg.port}"\
--set GITLAB_BACKUP_PATH"${cfg.backupPath}"\ --set GITLAB_BACKUP_PATH"${cfg.backupPath}"\
--set RAILS_ENV "production" --set RAILS_ENV "production"
''; '';
@ -77,43 +78,43 @@ in {
satelliteDir = mkOption { satelliteDir = mkOption {
type = types.str; type = types.str;
default = "/var/gitlab/git-satellites"; 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 { stateDir = mkOption {
type = types.str; type = types.str;
default = "/var/gitlab/state"; default = "/var/gitlab/state";
description = "The state directory, logs are stored here."; description = "Gitlab state directory, logs are stored here.";
}; };
backupPath = mkOption { backupPath = mkOption {
type = types.str; type = types.str;
default = cfg.stateDir + "/backup"; default = cfg.stateDir + "/backup";
description = "Path for backups."; description = "Gitlab path for backups.";
}; };
databaseHost = mkOption { databaseHost = mkOption {
type = types.str; type = types.str;
default = "127.0.0.1"; default = "127.0.0.1";
description = "Database hostname"; description = "Gitlab database hostname.";
}; };
databasePassword = mkOption { databasePassword = mkOption {
type = types.str; type = types.str;
default = ""; default = "";
description = "Database user password"; description = "Gitlab database user password.";
}; };
databaseName = mkOption { databaseName = mkOption {
type = types.str; type = types.str;
default = "gitlab"; default = "gitlab";
description = "Database name"; description = "Gitlab database name.";
}; };
databaseUsername = mkOption { databaseUsername = mkOption {
type = types.str; type = types.str;
default = "gitlab"; default = "gitlab";
description = "Database user"; description = "Gitlab database user.";
}; };
emailFrom = mkOption { emailFrom = mkOption {
@ -125,7 +126,13 @@ in {
host = mkOption { host = mkOption {
type = types.str; type = types.str;
default = config.networking.hostName; 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.";
}; };
}; };
}; };
@ -144,6 +151,7 @@ in {
services.redis.enable = mkDefault true; services.redis.enable = mkDefault true;
# We use postgres as the main data store. # We use postgres as the main data store.
services.postgresql.enable = mkDefault true; services.postgresql.enable = mkDefault true;
services.postgresql.package = mkDefault pkgs.postgresql;
# Use postfix to send out mails. # Use postfix to send out mails.
services.postfix.enable = mkDefault true; services.postfix.enable = mkDefault true;
@ -176,6 +184,7 @@ in {
environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml"; environment.GITLAB_SHELL_CONFIG_PATH = "${cfg.stateDir}/shell/config.yml";
environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret"; environment.GITLAB_SHELL_SECRET_PATH = "${cfg.stateDir}/config/gitlab_shell_secret";
environment.GITLAB_HOST = "${cfg.host}"; environment.GITLAB_HOST = "${cfg.host}";
environment.GITLAB_PORT = "${toString cfg.port}";
environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}";
environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}";
environment.RAILS_ENV = "production"; environment.RAILS_ENV = "production";
@ -209,6 +218,7 @@ in {
environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile"; environment.BUNDLE_GEMFILE = "${pkgs.gitlab}/share/gitlab/Gemfile";
environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}"; environment.GITLAB_EMAIL_FROM = "${cfg.emailFrom}";
environment.GITLAB_HOST = "${cfg.host}"; environment.GITLAB_HOST = "${cfg.host}";
environment.GITLAB_PORT = "${toString cfg.port}";
environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}"; environment.GITLAB_DATABASE_HOST = "${cfg.databaseHost}";
environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}"; environment.GITLAB_DATABASE_PASSWORD = "${cfg.databasePassword}";
environment.RAILS_ENV = "production"; environment.RAILS_ENV = "production";

19
nixos/tests/gitlab.nix Normal file
View File

@ -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");
'';
}

View File

@ -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 let
gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix); gemspec = map (gem: fetchurl { url=gem.url; sha256=gem.hash; }) (import ./Gemfile.nix);
@ -61,6 +61,10 @@ in stdenv.mkDerivation rec {
# See https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide: # See https://github.com/gitlabhq/gitlab-public-wiki/wiki/Trouble-Shooting-Guide:
bundle install -j4 --verbose --local --deployment --without development test mysql 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 # For reasons I don't understand "bundle exec" ignores the
# RAILS_ENV causing tests to be executed that fail because we're # RAILS_ENV causing tests to be executed that fail because we're
# not installing development and test gems above. Deleting the # not installing development and test gems above. Deleting the

View File

@ -1271,7 +1271,9 @@ let
gifsicle = callPackage ../tools/graphics/gifsicle { }; 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 { }; gitlab-shell = callPackage ../applications/version-management/gitlab-shell { };