2023-03-18 12:51:12 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.woodpecker;
|
|
|
|
|
|
|
|
hasRunner = (name: builtins.elem name cfg.runners);
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf (cfg.enable && hasRunner "exec") {
|
|
|
|
services.woodpecker-agents = {
|
|
|
|
agents.exec = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
WOODPECKER_SERVER = "localhost:${toString cfg.rpcPort}";
|
|
|
|
WOODPECKER_MAX_WORKFLOWS = "10";
|
|
|
|
WOODPECKER_BACKEND = "local";
|
|
|
|
WOODPECKER_FILTER_LABELS = "type=exec";
|
|
|
|
WOODPECKER_HEALTHCHECK = "false";
|
|
|
|
|
|
|
|
NIX_REMOTE = "daemon";
|
|
|
|
PAGER = "cat";
|
|
|
|
};
|
|
|
|
|
|
|
|
environmentFile = [ cfg.sharedSecretFile ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
# Adjust runner service for nix usage
|
|
|
|
systemd.services.woodpecker-agent-exec = {
|
|
|
|
# Might break deployment
|
|
|
|
restartIfChanged = false;
|
|
|
|
|
|
|
|
path = with pkgs; [
|
2023-07-28 18:05:56 +02:00
|
|
|
woodpecker-plugin-git
|
2023-03-18 12:51:12 +01:00
|
|
|
bash
|
|
|
|
coreutils
|
|
|
|
git
|
|
|
|
git-lfs
|
|
|
|
gnutar
|
|
|
|
gzip
|
|
|
|
nix
|
|
|
|
];
|
|
|
|
|
|
|
|
serviceConfig = {
|
2023-04-01 21:05:20 +02:00
|
|
|
# Same option as upstream, without @setuid
|
|
|
|
SystemCallFilter = lib.mkForce "~@clock @privileged @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @swap";
|
|
|
|
|
2023-03-18 12:51:12 +01:00
|
|
|
BindPaths = [
|
|
|
|
"/nix/var/nix/daemon-socket/socket"
|
|
|
|
"/run/nscd/socket"
|
|
|
|
];
|
|
|
|
BindReadOnlyPaths = [
|
|
|
|
"/etc/passwd:/etc/passwd"
|
|
|
|
"/etc/group:/etc/group"
|
|
|
|
"/nix/var/nix/profiles/system/etc/nix:/etc/nix"
|
|
|
|
"${config.environment.etc."ssh/ssh_known_hosts".source}:/etc/ssh/ssh_known_hosts"
|
|
|
|
"/etc/machine-id"
|
|
|
|
# channels are dynamic paths in the nix store, therefore we need to bind mount the whole thing
|
|
|
|
"/nix/"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|