lol

buildkite-agent: init at 2.1.8

* nixos module included
* install compiled binary
* only one platform now
* limited config options
* relies on providing ssh keys for agent

authored by

Paweł Pacana and committed by zimbatm.tngl.sh d2b58dd3 02a1408d

+149 -2
+1
lib/maintainers.nix
··· 282 282 pakhfn = "Fedor Pakhomov <pakhfn@gmail.com>"; 283 283 palo = "Ingolf Wanger <palipalo9@googlemail.com>"; 284 284 pashev = "Igor Pashev <pashev.igor@gmail.com>"; 285 + pawelpacana = "Paweł Pacana <pawel.pacana@gmail.com>"; 285 286 pesterhazy = "Paulus Esterhazy <pesterhazy@gmail.com>"; 286 287 peterhoeg = "Peter Hoeg <peter@hoeg.com>"; 287 288 peti = "Peter Simons <simons@cryp.to>";
+3 -2
nixos/modules/module-list.nix
··· 125 125 ./services/computing/torque/server.nix 126 126 ./services/computing/torque/mom.nix 127 127 ./services/computing/slurm/slurm.nix 128 + ./services/continuous-integration/buildkite-agent.nix 129 + ./services/continuous-integration/hydra/default.nix 128 130 ./services/continuous-integration/jenkins/default.nix 131 + ./services/continuous-integration/jenkins/job-builder.nix 129 132 ./services/continuous-integration/jenkins/slave.nix 130 - ./services/continuous-integration/jenkins/job-builder.nix 131 - ./services/continuous-integration/hydra/default.nix 132 133 ./services/databases/4store-endpoint.nix 133 134 ./services/databases/4store.nix 134 135 ./services/databases/couchdb.nix
+100
nixos/modules/services/continuous-integration/buildkite-agent.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.buildkite-agent; 7 + configFile = pkgs.writeText "buildkite-agent.cfg" 8 + '' 9 + token="${cfg.token}" 10 + name="${cfg.name}" 11 + meta-data="${cfg.meta-data}" 12 + hooks-path="${pkgs.buildkite-agent}/share/hooks" 13 + build-path="/var/lib/buildkite-agent/builds" 14 + bootstrap-script="${pkgs.buildkite-agent}/share/bootstrap.sh" 15 + ''; 16 + in 17 + 18 + { 19 + options = { 20 + services.buildkite-agent = { 21 + enable = mkEnableOption "buildkite-agent"; 22 + 23 + token = mkOption { 24 + type = types.str; 25 + description = '' 26 + The token from your Buildkite "Agents" page. 27 + ''; 28 + }; 29 + 30 + name = mkOption { 31 + type = types.str; 32 + description = '' 33 + The name of the agent. 34 + ''; 35 + }; 36 + 37 + meta-data = mkOption { 38 + type = types.str; 39 + default = ""; 40 + description = '' 41 + Meta data for the agent. 42 + ''; 43 + }; 44 + 45 + openssh = 46 + { privateKey = mkOption { 47 + type = types.str; 48 + description = '' 49 + Private agent key. 50 + ''; 51 + }; 52 + publicKey = mkOption { 53 + type = types.str; 54 + description = '' 55 + Public agent key. 56 + ''; 57 + }; 58 + }; 59 + }; 60 + }; 61 + 62 + config = mkIf config.services.buildkite-agent.enable { 63 + users.extraUsers.buildkite-agent = 64 + { name = "buildkite-agent"; 65 + home = "/var/lib/buildkite-agent"; 66 + createHome = true; 67 + description = "Buildkite agent user"; 68 + }; 69 + 70 + environment.systemPackages = [ pkgs.buildkite-agent ]; 71 + 72 + systemd.services.buildkite-agent = 73 + { description = "Buildkite Agent"; 74 + wantedBy = [ "multi-user.target" ]; 75 + after = [ "network.target" ]; 76 + environment.HOME = "/var/lib/buildkite-agent"; 77 + preStart = '' 78 + ${pkgs.coreutils}/bin/mkdir -m 0700 -p /var/lib/buildkite-agent/.ssh 79 + 80 + if ! [ -f /var/lib/buildkite-agent/.ssh/id_rsa ]; then 81 + echo "${cfg.openssh.privateKey}" > /var/lib/buildkite-agent/.ssh/id_rsa 82 + ${pkgs.coreutils}/bin/chmod 600 /var/lib/buildkite-agent/.ssh/id_rsa 83 + fi 84 + 85 + if ! [ -f /var/lib/buildkite-agent/.ssh/id_rsa.pub ]; then 86 + echo "${cfg.openssh.publicKey}" > /var/lib/buildkite-agent/.ssh/id_rsa.pub 87 + ${pkgs.coreutils}/bin/chmod 600 /var/lib/buildkite-agent/.ssh/id_rsa.pub 88 + fi 89 + ''; 90 + 91 + serviceConfig = 92 + { ExecStart = "${pkgs.buildkite-agent}/bin/buildkite-agent start --config ${configFile}"; 93 + User = "buildkite-agent"; 94 + RestartSec = 5; 95 + Restart = "on-failure"; 96 + TimeoutSec = 10; 97 + }; 98 + }; 99 + }; 100 + }
+43
pkgs/development/tools/continuous-integration/buildkite-agent/default.nix
··· 1 + { stdenv, fetchurl, makeWrapper, coreutils, git, openssh, bash, gnused, gnugrep }: 2 + 3 + stdenv.mkDerivation rec { 4 + version = "2.1.8"; 5 + name = "buildkite-agent-${version}"; 6 + dontBuild = true; 7 + 8 + src = fetchurl { 9 + url = "https://github.com/buildkite/agent/releases/download/v${version}/buildkite-agent-linux-386-${version}.tar.gz"; 10 + sha256 = "f54ca7da4379180700f5038779a7cbb1cef31d49f4a06c42702d68c34387c242"; 11 + }; 12 + 13 + nativeBuildInputs = [ makeWrapper ]; 14 + sourceRoot = "."; 15 + installPhase = '' 16 + install -Dt "$out/bin/" buildkite-agent 17 + 18 + mkdir -p $out/share 19 + mv hooks bootstrap.sh $out/share/ 20 + ''; 21 + 22 + postFixup = '' 23 + substituteInPlace $out/share/bootstrap.sh \ 24 + --replace "#!/bin/bash" "#!$(type -P bash)" 25 + wrapProgram $out/bin/buildkite-agent \ 26 + --set PATH '"${openssh}/bin/:${git}/bin:${coreutils}/bin:${gnused}/bin:${gnugrep}/bin:$PATH"' 27 + ''; 28 + 29 + meta = { 30 + description = "Build runner for buildkite.com"; 31 + longDescription = '' 32 + The buildkite-agent is a small, reliable, and cross-platform build runner 33 + that makes it easy to run automated builds on your own infrastructure. 34 + It’s main responsibilities are polling buildkite.com for work, running 35 + build jobs, reporting back the status code and output log of the job, 36 + and uploading the job's artifacts. 37 + ''; 38 + homepage = https://buildkite.com/docs/agent; 39 + license = stdenv.lib.licenses.mit; 40 + maintainers = [ stdenv.lib.maintainers.pawelpacana ]; 41 + platforms = stdenv.lib.platforms.linux; 42 + }; 43 + }
+2
pkgs/top-level/all-packages.nix
··· 5951 5951 inherit (pythonPackages) twisted; 5952 5952 }; 5953 5953 5954 + buildkite-agent = callPackage ../development/tools/continuous-integration/buildkite-agent { }; 5955 + 5954 5956 byacc = callPackage ../development/tools/parsing/byacc { }; 5955 5957 5956 5958 cargo = callPackage ../development/tools/build-managers/cargo {