gitlab-runner: make v1 runner available

gitlab-runner 9.0.0 is only compatible with gitlab >= 9.0
gitlab-runner1 1.11.1 is only compatible with gitlab < 9.4
This commit is contained in:
Pascal Bach 2017-03-23 22:45:23 +01:00
parent 783e1ce431
commit 8373124202
3 changed files with 79 additions and 1 deletions

View File

@ -20,6 +20,14 @@ in
description = "The working directory used";
};
package = mkOption {
description = "Gitlab Runner package to use";
default = pkgs.gitlab-runner;
defaultText = "pkgs.gitlab-runner";
type = types.package;
example = literalExample "pkgs.gitlab-runner_1_11";
};
};
config = mkIf cfg.enable {
@ -29,7 +37,7 @@ in
requires = [ "docker.service" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
ExecStart = ''${pkgs.gitlab-runner.bin}/bin/gitlab-runner run \
ExecStart = ''${cfg.package.bin}/bin/gitlab-runner run \
--working-directory ${cfg.workDir} \
--config ${configFile} \
--service gitlab-runner \
@ -38,6 +46,9 @@ in
};
};
# Make the gitlab-runner command availabe so users can query the runner
environment.systemPackages = [ cfg.package ];
users.extraUsers.gitlab-runner = {
group = "gitlab-runner";
extraGroups = [ "docker" ];

View File

@ -0,0 +1,66 @@
{ lib, buildGoPackage, fetchFromGitLab, fetchurl, go-bindata }:
let
version = "1.11.1";
# Gitlab runner embeds some docker images these are prebuilt for arm and x86_64
docker_x86_64 = fetchurl {
url = "https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/v${version}/docker/prebuilt-x86_64.tar.xz";
sha256 = "1fahwvwdli6glxsljrd030x15y18jwk72lg1xmrgms409r9y308m";
};
docker_arm = fetchurl {
url = "https://gitlab-ci-multi-runner-downloads.s3.amazonaws.com/v${version}/docker/prebuilt-arm.tar.xz";
sha256 = "0nqda27qcb6r1p2xc2973g08fwb8cnmyc9rswy6776r8ypagn2zw";
};
in
buildGoPackage rec {
inherit version;
name = "gitlab-runner-${version}";
goPackagePath = "gitlab.com/gitlab-org/gitlab-ci-multi-runner";
commonPackagePath = "${goPackagePath}/common";
buildFlagsArray = ''
-ldflags=
-X ${commonPackagePath}.NAME=gitlab-runner
-X ${commonPackagePath}.VERSION=${version}
-X ${commonPackagePath}.REVISION=v${version}
'';
src = fetchFromGitLab {
owner = "gitlab-org";
repo = "gitlab-ci-multi-runner";
rev = "v${version}";
sha256 = "0ix00p9f01fg8m6p3b1c20hqrcv7pivh6hq92pb9qyiyzmcfap47";
};
buildInputs = [ go-bindata ];
preBuild = ''
(
# go-bindata names the assets after the filename thus we create a symlink with the name we want
cd go/src/${goPackagePath}
ln -sf ${docker_x86_64} prebuilt-x86_64.tar.xz
ln -sf ${docker_arm} prebuilt-arm.tar.xz
go-bindata \
-pkg docker \
-nocompress \
-nomemcopy \
-o executors/docker/bindata.go \
prebuilt-x86_64.tar.xz \
prebuilt-arm.tar.xz
)
'';
postInstall = ''
install -d $out/bin
# The recommended name is gitlab-runner so we create a symlink with that name
ln -sf gitlab-ci-multi-runner $bin/bin/gitlab-runner
'';
meta = with lib; {
description = "GitLab Runner the continuous integration executor of GitLab";
license = licenses.mit;
homepage = "https://about.gitlab.com/gitlab-ci/";
platforms = platforms.unix;
maintainers = [ lib.maintainers.bachp ];
};
}

View File

@ -1963,6 +1963,7 @@ with pkgs;
gitlab = callPackage ../applications/version-management/gitlab { };
gitlab-runner = callPackage ../development/tools/continuous-integration/gitlab-runner { };
gitlab-runner_1_11 = callPackage ../development/tools/continuous-integration/gitlab-runner/v1.nix { };
gitlab-shell = callPackage ../applications/version-management/gitlab-shell { };