Setup gitlab-runner

This commit is contained in:
Charlotte Van Petegem 2023-01-28 11:50:11 +01:00
parent 59832662dd
commit 4895337cef
No known key found for this signature in database
GPG key ID: 019E764B7184435A
7 changed files with 85 additions and 2 deletions

View file

@ -53,6 +53,7 @@
enable = true;
count = 6;
};
git.runner.enable = true;
};
};

View file

@ -51,6 +51,14 @@
device = "zdata/data";
fsType = "zfs";
};
"/var/lib/private/gitlab-runner" = {
device = "zdata/big-apps/gitlab-runner";
fsType = "zfs";
};
"/var/lib/docker" = {
device = "zdata/big-apps/docker";
fsType = "zfs";
};
"/boot/ESP0" = {
device = "/dev/disk/by-uuid/6ED1-0638";
fsType = "vfat";

View file

@ -1,6 +1,8 @@
{ config, lib, pkgs, ... }:
{
imports = [ ./runner.nix ];
options.chvp.services.git.enable = lib.mkOption {
default = false;
example = true;

View file

@ -0,0 +1,71 @@
{ config, lib, pkgs, ... }:
{
options.chvp.services.git.runner.enable = lib.mkOption {
default = false;
example = true;
};
config = lib.mkIf config.chvp.services.git.runner.enable {
services.gitlab-runner = {
enable = true;
services = {
nix = {
registrationConfigFile = config.age.secrets."passwords/services/gitlab-runner/registration".path;
dockerImage = "alpine";
dockerVolumes = [
"/nix/store:/nix/store:ro"
"/nix/var/nix/db:/nix/var/nix/db:ro"
"/nix/var/nix/daemon-socket:/nix/var/nix/daemon-socket:ro"
];
dockerDisableCache = true;
preBuildScript = pkgs.writeScript "setup-container" ''
mkdir -p -m 0755 /nix/var/log/nix/drvs
mkdir -p -m 0755 /nix/var/nix/gcroots
mkdir -p -m 0755 /nix/var/nix/profiles
mkdir -p -m 0755 /nix/var/nix/temproots
mkdir -p -m 0755 /nix/var/nix/userpool
mkdir -p -m 1777 /nix/var/nix/gcroots/per-user
mkdir -p -m 1777 /nix/var/nix/profiles/per-user
mkdir -p -m 0755 /nix/var/nix/profiles/per-user/root
mkdir -p -m 0700 "$HOME/.nix-defexpr"
. ${pkgs.nix}/etc/profile.d/nix.sh
${pkgs.nix}/bin/nix-env -i ${lib.concatStringsSep " " (with pkgs; [ nix cacert git openssh ])}
${pkgs.nix}/bin/nix-channel --add https://nixos.org/channels/nixpkgs-unstable
${pkgs.nix}/bin/nix-channel --update nixpkgs
'';
environmentVariables = {
ENV = "/etc/profile";
USER = "root";
NIX_REMOTE = "daemon";
PATH = "/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/bin:/sbin:/usr/bin:/usr/sbin";
NIX_SSL_CERT_FILE = "/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt";
};
tagList = [ "nix" ];
};
docker-images = {
registrationConfigFile = config.age.secrets."passwords/services/gitlab-runner/registration".path;
dockerImage = "docker:stable";
dockerVolumes = [
"/var/run/docker.sock:/var/run/docker.sock"
];
tagList = [ "docker-images" ];
};
default = {
registrationConfigFile = config.age.secrets."passwords/services/gitlab-runner/registration".path;
dockerImage = "debian:stable";
};
};
};
virtualisation.docker = {
enable = true;
storageDriver = "zfs";
};
age.secrets."passwords/services/gitlab-runner/registration" = {
file = ../../../secrets/passwords/services/gitlab-runner/registration.age;
};
};
}

View file

@ -58,6 +58,7 @@ in
"secrets/passwords/services/git/jws.age".publicKeys = [ lasting-integrity ] ++ users;
"secrets/passwords/services/git/otp.age".publicKeys = [ lasting-integrity ] ++ users;
"secrets/passwords/services/git/secret.age".publicKeys = [ lasting-integrity ] ++ users;
"secrets/passwords/services/gitlab-runner/registration.age".publicKeys = [ urithiru ] ++ users;
"secrets/passwords/services/mastodon/otp.age".publicKeys = [ lasting-integrity ] ++ users;
"secrets/passwords/services/mastodon/key.age".publicKeys = [ lasting-integrity ] ++ users;