71 lines
2.1 KiB
Nix
Raw Normal View History

2024-01-09 23:11:11 -05:00
# Gitea Actions is a CI/CD service for the Gitea source code server, meaning it
# allows us to run code operations (such as testing or deploys) when our git
# repositories are updated. Any machine can act as a Gitea Action Runner, so
# the Runners don't necessarily need to be running Gitea. All we need is an API
# key for Gitea to connect to it and register ourselves as a Runner.
2024-04-20 09:42:06 -04:00
{
config,
pkgs,
lib,
...
}:
2023-07-10 16:00:48 -06:00
2025-01-20 22:35:40 -05:00
let
cfg = config.nmasur.presets.services.gitea-runner-local;
in
2023-07-10 16:00:48 -06:00
{
2025-01-20 22:35:40 -05:00
options.nmasur.presets.services.gitea-runner-local.enable =
lib.mkEnableOption "Gitea Actions runner local to Gitea instance";
2023-07-10 16:00:48 -06:00
2025-01-20 22:35:40 -05:00
config = lib.mkIf cfg.enable {
2023-07-10 16:00:48 -06:00
services.gitea-actions-runner.instances.${config.networking.hostName} = {
enable = true;
labels = [
# Provide a Debian base with NodeJS for actions
2023-07-16 03:33:35 +00:00
# "debian-latest:docker://node:18-bullseye"
2023-07-10 16:00:48 -06:00
# Fake the Ubuntu name, because Node provides no Ubuntu builds
2023-07-16 03:33:35 +00:00
# "ubuntu-latest:docker://node:18-bullseye"
2023-07-10 16:00:48 -06:00
# Provide native execution on the host using below packages
"native:host"
];
hostPackages = with pkgs; [
bash
coreutils
curl
gawk
gitMinimal
gnused
nodejs
wget
];
name = config.networking.hostName;
url = "https://${config.hostnames.git}";
tokenFile = config.secrets.giteaRunnerToken.dest;
};
# Make sure the runner doesn't start until after Gitea
2024-04-20 09:42:06 -04:00
systemd.services."gitea-runner-${config.networking.hostName}".after = [ "gitea.service" ];
# API key needed to connect to Gitea
2023-07-16 03:33:35 +00:00
secrets.giteaRunnerToken = {
source = ../../../private/gitea-runner-token.age; # TOKEN=xyz
dest = "${config.secretsDirectory}/gitea-runner-token";
};
systemd.services.giteaRunnerToken-secret = {
requiredBy = [
"gitea-runner-${
config.services.gitea-actions-runner.instances.${config.networking.hostName}.name
}.service"
];
before = [
"gitea-runner-${
config.services.gitea-actions-runner.instances.${config.networking.hostName}.name
}.service"
];
};
2023-07-10 16:00:48 -06:00
};
}