Add Forgejo Actions Runner with sops secrets

This commit is contained in:
ashisgreat22 2026-03-19 14:05:51 +01:00
parent b6abc4a1cf
commit 837e71b69d
2 changed files with 51 additions and 0 deletions

View file

@ -146,6 +146,18 @@
enable = true; enable = true;
domain = "git.ashisgreat.xyz"; domain = "git.ashisgreat.xyz";
disableRegistration = true; # Admin only disableRegistration = true; # Admin only
runner = {
enable = true;
tokenFile = config.sops.templates."forgejo-runner.env".path;
};
};
# Forgejo runner secrets
sops.secrets.forgejo_runner_token = { };
sops.templates."forgejo-runner.env" = {
content = ''
TOKEN=${config.sops.placeholder.forgejo_runner_token}
'';
}; };
# === CrowdSec === # === CrowdSec ===

View file

@ -38,6 +38,28 @@ in
default = true; default = true;
description = "Disable public user registration"; description = "Disable public user registration";
}; };
runner = {
enable = lib.mkEnableOption "Forgejo Actions Runner";
name = lib.mkOption {
type = lib.types.str;
default = config.networking.hostName;
description = "Name of the runner";
};
tokenFile = lib.mkOption {
type = lib.types.path;
description = "Path to the token file (containing TOKEN=...)";
};
labels = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [
"native:host"
"ubuntu-latest:docker://node:20-bullseye"
"debian-latest:docker://node:20-bullseye"
];
description = "Labels for the runner";
};
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@ -87,5 +109,22 @@ in
myModules.backup.paths = [ myModules.backup.paths = [
config.services.forgejo.stateDir config.services.forgejo.stateDir
]; ];
# Actions Runner
services.gitea-actions-runner = lib.mkIf cfg.runner.enable {
package = pkgs.forgejo-runner;
instances.default = {
enable = true;
name = cfg.runner.name;
url = "https://${cfg.domain}";
tokenFile = cfg.runner.tokenFile;
labels = cfg.runner.labels;
settings = {
container = {
network = "bridge";
};
};
};
};
}; };
} }