2023-11-13 13:24:08 +00:00
|
|
|
{ lib, pkgs, config, ... }:
|
|
|
|
let
|
|
|
|
inherit (builtins) toJSON;
|
|
|
|
inherit (lib) mkForce;
|
|
|
|
inherit (lib.my.c) pubDomain;
|
|
|
|
|
|
|
|
cfgFile = pkgs.writeText "gitea-actions-runner.yaml" (toJSON {
|
|
|
|
container = {
|
2023-12-09 17:19:18 +00:00
|
|
|
network = "podman";
|
2023-11-17 02:36:32 +00:00
|
|
|
privileged = true;
|
2023-11-13 13:24:08 +00:00
|
|
|
};
|
2023-11-16 19:39:53 +00:00
|
|
|
cache = {
|
|
|
|
enabled = true;
|
|
|
|
dir = "/var/cache/gitea-runner";
|
|
|
|
};
|
2023-11-13 13:24:08 +00:00
|
|
|
});
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = {
|
2023-11-16 19:39:53 +00:00
|
|
|
fileSystems = {
|
|
|
|
"/var/cache/gitea-runner" = {
|
|
|
|
device = "/dev/disk/by-label/actions-cache";
|
|
|
|
fsType = "ext4";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-13 13:24:08 +00:00
|
|
|
services = {
|
|
|
|
gitea-actions-runner.instances = {
|
|
|
|
main = {
|
|
|
|
enable = true;
|
|
|
|
name = "main-docker";
|
2023-11-17 02:36:32 +00:00
|
|
|
labels = [
|
2023-11-18 15:59:48 +00:00
|
|
|
"debian-node-bullseye:docker://node:18-bullseye"
|
2023-11-17 02:36:32 +00:00
|
|
|
"ubuntu-22.04:docker://git.nul.ie/dev/actions-ubuntu:22.04"
|
|
|
|
];
|
2023-11-13 13:24:08 +00:00
|
|
|
url = "https://git.${pubDomain}";
|
|
|
|
tokenFile = config.age.secrets."gitea/actions-runner.env".path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users = with lib.my.c.ids; {
|
|
|
|
users = {
|
|
|
|
gitea-runner = {
|
|
|
|
isSystemUser = true;
|
|
|
|
uid = uids.gitea-runner;
|
|
|
|
group = "gitea-runner";
|
|
|
|
home = "/var/lib/gitea-runner";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
groups = {
|
|
|
|
gitea-runner.gid = gids.gitea-runner;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd = {
|
|
|
|
services = {
|
|
|
|
gitea-runner-main.serviceConfig = {
|
|
|
|
# Needs to be able to read its secrets
|
2023-11-16 19:39:53 +00:00
|
|
|
CacheDirectory = "gitea-runner";
|
2023-11-13 13:24:08 +00:00
|
|
|
DynamicUser = mkForce false;
|
|
|
|
User = "gitea-runner";
|
|
|
|
Group = "gitea-runner";
|
|
|
|
ExecStart = mkForce "${config.services.gitea-actions-runner.package}/bin/act_runner -c ${cfgFile} daemon";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
my = {
|
|
|
|
secrets.files = {
|
|
|
|
"gitea/actions-runner.env" = {
|
|
|
|
owner = "gitea-runner";
|
|
|
|
group = "gitea-runner";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|