2023-06-17 18:37:06 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.skynet_gitlab_runner;
|
|
|
|
in {
|
|
|
|
imports = [
|
|
|
|
|
|
|
|
];
|
|
|
|
|
|
|
|
options.services.skynet_gitlab_runner = {
|
|
|
|
enable = mkEnableOption "Skynet Gitlab Runner";
|
|
|
|
|
|
|
|
runner = {
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
gitlab = mkOption {
|
|
|
|
default = "https://gitlab.skynet.ie";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
description = mkOption {
|
|
|
|
default = cfg.runner.name;
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
docker = {
|
|
|
|
image = mkOption {
|
|
|
|
default = "alpine:latest";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
|
|
|
|
cleanup_dates = mkOption {
|
|
|
|
# https://man.archlinux.org/man/systemd.time.7#CALENDAR_EVENTS
|
|
|
|
# it will use a lot of storage so clear it daily, may change to hourly if required
|
|
|
|
default = "daily";
|
|
|
|
type = types.str;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# https://search.nixos.org/options?from=0&size=50&sort=alpha_desc&type=packages&query=services.gitlab-runner.
|
2023-07-15 14:05:57 +00:00
|
|
|
environment.systemPackages = [
|
|
|
|
pkgs.gitlab-runner
|
|
|
|
];
|
2023-06-17 18:37:06 +00:00
|
|
|
|
|
|
|
age.secrets."${cfg.runner.name}".file = ../secrets/gitlab/runners/${cfg.runner.name}.age;
|
|
|
|
|
|
|
|
services.gitlab-runner = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
clear-docker-cache = {
|
|
|
|
enable = true;
|
|
|
|
dates = cfg.runner.docker.cleanup_dates;
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
# might make a function later to have multiple runners, might never need it though
|
|
|
|
"${cfg.runner.name}" = {
|
|
|
|
cloneUrl = cfg.runner.gitlab;
|
|
|
|
description = cfg.runner.description;
|
|
|
|
registrationConfigFile = config.age.secrets."${cfg.runner.name}".path;
|
|
|
|
dockerImage = cfg.runner.docker.image;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|