forked from pub-solar/os
ci-runner experiment
This commit is contained in:
parent
5e836f6f31
commit
1cec43be02
|
@ -1,8 +1,15 @@
|
|||
{ lib, config, pkgs, self, ... }:
|
||||
{ lib, config, pkgs, self, dockerTools, ... }:
|
||||
|
||||
with lib;
|
||||
let
|
||||
bootstrap = pkgs.writeScript "bootstrap.sh" ''
|
||||
runnerImageName = "ci-runner-docker-drone-exec";
|
||||
runnerImage = dockerTools.buildImage {
|
||||
name = runnerImageName;
|
||||
tag = "latest";
|
||||
|
||||
fromImageName = "debian";
|
||||
|
||||
runAsRoot = ''
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
@ -10,7 +17,7 @@ let
|
|||
apt update
|
||||
apt install --yes curl git sudo xz-utils
|
||||
|
||||
adduser --system --uid 999 build
|
||||
adduser --system --uid 9999 build
|
||||
chown build /nix
|
||||
|
||||
sudo -u build curl -L https://nixos.org/nix/install > install
|
||||
|
@ -28,6 +35,11 @@ let
|
|||
|
||||
curl -L https://github.com/drone-runners/drone-runner-exec/releases/latest/download/drone_runner_exec_linux_amd64.tar.gz | tar xz
|
||||
sudo install -t /usr/local/bin drone-runner-exec
|
||||
'';
|
||||
};
|
||||
|
||||
startup = pkgs.writeScript "startup.sh" ''
|
||||
chown build /nix
|
||||
|
||||
if [ ! -f /run/vars ]; then
|
||||
exit 1
|
||||
|
@ -38,6 +50,7 @@ let
|
|||
|
||||
su - -s /bin/bash build sh -c "/usr/local/bin/drone-runner-exec daemon /run/runtime-vars"
|
||||
'';
|
||||
|
||||
psCfg = config.pub-solar;
|
||||
cfg = config.pub-solar.ci-runner;
|
||||
in
|
||||
|
@ -62,7 +75,7 @@ in
|
|||
|
||||
runnerEnvironment = lib.mkOption {
|
||||
description = ''
|
||||
Additional environment vars added to the vars file on container runtime
|
||||
Additional environment variables added to the vars file on container runtime
|
||||
'';
|
||||
default = {};
|
||||
};
|
||||
|
@ -84,15 +97,16 @@ in
|
|||
oci-containers = {
|
||||
backend = "docker";
|
||||
containers."drone-exec-runner" = {
|
||||
image = "debian";
|
||||
image = runnerImageName;
|
||||
imageFile = runnerImage;
|
||||
autoStart = true;
|
||||
entrypoint = "bash";
|
||||
cmd = [ "/bootstrap.sh" ];
|
||||
cmd = [ "/startup.sh" ];
|
||||
|
||||
volumes = [
|
||||
"${cfg.runnerVarsFile}:/run/vars"
|
||||
"${cfg.nixCacheLocation}:/nix"
|
||||
"${bootstrap}:/bootstrap.sh"
|
||||
"${startup}:/startup.sh"
|
||||
];
|
||||
|
||||
environment = cfg.runnerEnvironment;
|
||||
|
|
Loading…
Reference in a new issue