From b2728bf1de627677acdaed39b430165863a54558 Mon Sep 17 00:00:00 2001 From: klaatu Date: Sat, 4 Apr 2026 06:18:10 +0000 Subject: [PATCH] feat: add gitea-runner NixOS module --- modules/nixos/gitea-runner.nix | 65 ++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 modules/nixos/gitea-runner.nix diff --git a/modules/nixos/gitea-runner.nix b/modules/nixos/gitea-runner.nix new file mode 100644 index 0000000..ada7a8c --- /dev/null +++ b/modules/nixos/gitea-runner.nix @@ -0,0 +1,65 @@ +{ + config, + lib, + pkgs, + ... +}: +let + cfg = config.greg.gitea-runner; + hostname = config.networking.hostName; + + # Determine extra labels based on host role + roleLabels = + if builtins.elem hostname [ "isaiah" "jeremiah" "zeke" ] then + [ "bare-metal" ] + else if hostname == "linode" then + [ "linode" ] + else + [ ]; +in +{ + options.greg.gitea-runner = { + enable = lib.mkEnableOption "Enable Gitea Actions runner (exec/shell mode)"; + + hostnameLabel = lib.mkOption { + type = lib.types.str; + default = config.networking.hostName; + description = "Label identifying this host in the runner pool (defaults to hostname)"; + }; + + tokenFile = lib.mkOption { + type = lib.types.path; + description = '' + Path to the file containing the runner registration token. + Wire in your agenix secret path here, e.g.: + config.age.secrets.gitea-runner-token.path + ''; + }; + + threads = lib.mkOption { + type = lib.types.int; + default = 4; + description = "Maximum number of concurrent jobs"; + }; + }; + + config = lib.mkIf cfg.enable { + services.gitea-actions-runner = { + package = pkgs.gitea-actions-runner; + instances.${hostname} = { + enable = true; + url = "https://src.thehellings.com"; + tokenFile = cfg.tokenFile; + labels = + [ + "self-hosted" + cfg.hostnameLabel + ] + ++ roleLabels; + settings = { + runner.capacity = cfg.threads; + }; + }; + }; + }; +}