buildkite-agent: 2.1.13 -> 2.6.6
Build the package from source Re-organise the module a bit to allow custom version of the package
This commit is contained in:
parent
525e121626
commit
96b339fbc9
@ -9,9 +9,8 @@ let
|
|||||||
token="${cfg.token}"
|
token="${cfg.token}"
|
||||||
name="${cfg.name}"
|
name="${cfg.name}"
|
||||||
meta-data="${cfg.meta-data}"
|
meta-data="${cfg.meta-data}"
|
||||||
hooks-path="${pkgs.buildkite-agent}/share/hooks"
|
hooks-path="${cfg.package}/share/hooks"
|
||||||
build-path="/var/lib/buildkite-agent/builds"
|
build-path="${cfg.dataDir}"
|
||||||
bootstrap-script="${pkgs.buildkite-agent}/share/bootstrap.sh"
|
|
||||||
'';
|
'';
|
||||||
in
|
in
|
||||||
|
|
||||||
@ -20,6 +19,26 @@ in
|
|||||||
services.buildkite-agent = {
|
services.buildkite-agent = {
|
||||||
enable = mkEnableOption "buildkite-agent";
|
enable = mkEnableOption "buildkite-agent";
|
||||||
|
|
||||||
|
package = mkOption {
|
||||||
|
default = pkgs.buildkite-agent;
|
||||||
|
defaultText = "pkgs.buildkite-agent";
|
||||||
|
description = "Which buildkite-agent derivation to use";
|
||||||
|
type = types.package;
|
||||||
|
};
|
||||||
|
|
||||||
|
dataDir = mkOption {
|
||||||
|
default = "/var/lib/buildkite-agent";
|
||||||
|
description = "The workdir for the agent";
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
runtimePackages = mkOption {
|
||||||
|
default = [ pkgs.nix ];
|
||||||
|
defaultText = "[ pkgs.nix ]";
|
||||||
|
description = "Add programs to the buildkite-agent environment";
|
||||||
|
type = types.listOf types.package;
|
||||||
|
};
|
||||||
|
|
||||||
token = mkOption {
|
token = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
description = ''
|
description = ''
|
||||||
@ -62,27 +81,31 @@ in
|
|||||||
config = mkIf config.services.buildkite-agent.enable {
|
config = mkIf config.services.buildkite-agent.enable {
|
||||||
users.extraUsers.buildkite-agent =
|
users.extraUsers.buildkite-agent =
|
||||||
{ name = "buildkite-agent";
|
{ name = "buildkite-agent";
|
||||||
home = "/var/lib/buildkite-agent";
|
home = cfg.dataDir;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
description = "Buildkite agent user";
|
description = "Buildkite agent user";
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.systemPackages = [ pkgs.buildkite-agent ];
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
systemd.services.buildkite-agent =
|
systemd.services.buildkite-agent =
|
||||||
{ description = "Buildkite Agent";
|
{ description = "Buildkite Agent";
|
||||||
wantedBy = [ "multi-user.target" ];
|
wantedBy = [ "multi-user.target" ];
|
||||||
after = [ "network.target" ];
|
after = [ "network.target" ];
|
||||||
environment.HOME = "/var/lib/buildkite-agent";
|
path = cfg.runtimePackages;
|
||||||
|
environment = config.networking.proxy.envVars // {
|
||||||
|
HOME = cfg.dataDir;
|
||||||
|
NIX_REMOTE = "daemon";
|
||||||
|
};
|
||||||
preStart = ''
|
preStart = ''
|
||||||
${pkgs.coreutils}/bin/mkdir -m 0700 -p /var/lib/buildkite-agent/.ssh
|
${pkgs.coreutils}/bin/mkdir -m 0700 -p ${cfg.dataDir}/.ssh
|
||||||
|
|
||||||
echo "${cfg.openssh.privateKey}" > /var/lib/buildkite-agent/.ssh/id_rsa
|
echo "${cfg.openssh.privateKey}" > ${cfg.dataDir}/.ssh/id_rsa
|
||||||
${pkgs.coreutils}/bin/chmod 600 /var/lib/buildkite-agent/.ssh/id_rsa
|
${pkgs.coreutils}/bin/chmod 600 ${cfg.dataDir}/.ssh/id_rsa
|
||||||
|
|
||||||
echo "${cfg.openssh.publicKey}" > /var/lib/buildkite-agent/.ssh/id_rsa.pub
|
echo "${cfg.openssh.publicKey}" > ${cfg.dataDir}/.ssh/id_rsa.pub
|
||||||
${pkgs.coreutils}/bin/chmod 600 /var/lib/buildkite-agent/.ssh/id_rsa.pub
|
${pkgs.coreutils}/bin/chmod 600 ${cfg.dataDir}/.ssh/id_rsa.pub
|
||||||
'';
|
'';
|
||||||
|
|
||||||
serviceConfig =
|
serviceConfig =
|
||||||
{ ExecStart = "${pkgs.buildkite-agent}/bin/buildkite-agent start --config ${configFile}";
|
{ ExecStart = "${pkgs.buildkite-agent}/bin/buildkite-agent start --config ${configFile}";
|
||||||
|
@ -1,32 +1,38 @@
|
|||||||
{ stdenv, fetchurl, makeWrapper, coreutils, git, openssh, bash, gnused, gnugrep }:
|
{ stdenv, buildGoPackage, fetchFromGitHub, makeWrapper, coreutils, git, openssh, bash, gnused, gnugrep }:
|
||||||
|
let
|
||||||
stdenv.mkDerivation rec {
|
version = "2.6.6";
|
||||||
version = "2.1.13";
|
goPackagePath = "github.com/buildkite/agent";
|
||||||
|
in
|
||||||
|
buildGoPackage {
|
||||||
name = "buildkite-agent-${version}";
|
name = "buildkite-agent-${version}";
|
||||||
dontBuild = true;
|
|
||||||
|
|
||||||
src = fetchurl {
|
inherit goPackagePath;
|
||||||
url = "https://github.com/buildkite/agent/releases/download/v${version}/buildkite-agent-linux-386-${version}.tar.gz";
|
|
||||||
sha256 = "bd40c2ba37b3b54b875241a32b62190a4cf4c15e2513c573f1626a3ca35c8657";
|
src = fetchFromGitHub {
|
||||||
|
owner = "buildkite";
|
||||||
|
repo = "agent";
|
||||||
|
rev = "v${version}";
|
||||||
|
sha256 = "0rpi63mfzlm39517l4xjcka3m4dnfjzwvpi0i1rpf1z2288cnkyx";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper ];
|
nativeBuildInputs = [ makeWrapper ];
|
||||||
sourceRoot = ".";
|
|
||||||
installPhase = ''
|
|
||||||
install -Dt "$out/bin/" buildkite-agent
|
|
||||||
|
|
||||||
mkdir -p $out/share
|
postInstall = ''
|
||||||
mv hooks bootstrap.sh $out/share/
|
# Install bootstrap.sh
|
||||||
|
mkdir -p $bin/libexec/buildkite-agent
|
||||||
|
cp $NIX_BUILD_TOP/go/src/${goPackagePath}/templates/bootstrap.sh $bin/libexec/buildkite-agent
|
||||||
|
sed -e "s|#!/bin/bash|#!${bash}/bin/bash|g" -i $bin/libexec/buildkite-agent/bootstrap.sh
|
||||||
|
|
||||||
|
# Fix binary name
|
||||||
|
mv $bin/bin/{agent,buildkite-agent}
|
||||||
|
|
||||||
|
# These are runtime dependencies
|
||||||
|
wrapProgram $bin/bin/buildkite-agent \
|
||||||
|
--prefix PATH : '${stdenv.lib.makeBinPath [ openssh git coreutils gnused gnugrep ]}' \
|
||||||
|
--set BUILDKITE_BOOTSTRAP_SCRIPT_PATH $bin/libexec/buildkite-agent/bootstrap.sh
|
||||||
'';
|
'';
|
||||||
|
|
||||||
postFixup = ''
|
meta = with stdenv.lib; {
|
||||||
substituteInPlace $out/share/bootstrap.sh \
|
|
||||||
--replace "#!/bin/bash" "#!$(type -P bash)"
|
|
||||||
wrapProgram $out/bin/buildkite-agent \
|
|
||||||
--set PATH '"${stdenv.lib.makeBinPath [ openssh git coreutils gnused gnugrep ]}:$PATH"'
|
|
||||||
'';
|
|
||||||
|
|
||||||
meta = {
|
|
||||||
description = "Build runner for buildkite.com";
|
description = "Build runner for buildkite.com";
|
||||||
longDescription = ''
|
longDescription = ''
|
||||||
The buildkite-agent is a small, reliable, and cross-platform build runner
|
The buildkite-agent is a small, reliable, and cross-platform build runner
|
||||||
@ -36,8 +42,8 @@ stdenv.mkDerivation rec {
|
|||||||
and uploading the job's artifacts.
|
and uploading the job's artifacts.
|
||||||
'';
|
'';
|
||||||
homepage = https://buildkite.com/docs/agent;
|
homepage = https://buildkite.com/docs/agent;
|
||||||
license = stdenv.lib.licenses.mit;
|
license = licenses.mit;
|
||||||
maintainers = [ stdenv.lib.maintainers.pawelpacana ];
|
maintainers = with maintainers; [ pawelpacana zimbatm ];
|
||||||
platforms = stdenv.lib.platforms.linux;
|
platforms = platforms.linux;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user