2023-03-15 16:39:30 +00:00
|
|
|
{ config
|
|
|
|
, lib
|
|
|
|
, pkgs
|
|
|
|
, ...
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.woodpecker-server;
|
|
|
|
in
|
|
|
|
{
|
2024-07-27 06:49:29 +00:00
|
|
|
meta.maintainers = with lib.maintainers; [ ambroisie ];
|
2023-03-15 16:39:30 +00:00
|
|
|
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.woodpecker-server = {
|
2024-04-21 15:54:59 +00:00
|
|
|
enable = lib.mkEnableOption "the Woodpecker-Server, a CI/CD application for automatic builds, deployments and tests";
|
2024-01-02 11:29:13 +00:00
|
|
|
package = lib.mkPackageOption pkgs "woodpecker-server" { };
|
2023-03-15 16:39:30 +00:00
|
|
|
environment = lib.mkOption {
|
|
|
|
default = { };
|
|
|
|
type = lib.types.attrsOf lib.types.str;
|
|
|
|
example = lib.literalExpression
|
|
|
|
''
|
|
|
|
{
|
|
|
|
WOODPECKER_HOST = "https://woodpecker.example.com";
|
|
|
|
WOODPECKER_OPEN = "true";
|
|
|
|
WOODPECKER_GITEA = "true";
|
|
|
|
WOODPECKER_GITEA_CLIENT = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
|
|
WOODPECKER_GITEA_URL = "https://git.example.com";
|
|
|
|
}
|
|
|
|
'';
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "woodpecker-server config environment variables, for other options read the [documentation](https://woodpecker-ci.org/docs/administration/server-config)";
|
2023-03-15 16:39:30 +00:00
|
|
|
};
|
|
|
|
environmentFile = lib.mkOption {
|
2023-11-16 04:20:00 +00:00
|
|
|
type = with lib.types; coercedTo path (f: [ f ]) (listOf path);
|
|
|
|
default = [ ];
|
|
|
|
example = [ "/root/woodpecker-server.env" ];
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2023-03-15 16:39:30 +00:00
|
|
|
File to load environment variables
|
|
|
|
from. This is helpful for specifying secrets.
|
|
|
|
Example content of environmentFile:
|
|
|
|
```
|
|
|
|
WOODPECKER_AGENT_SECRET=your-shared-secret-goes-here
|
|
|
|
WOODPECKER_GITEA_SECRET=gto_**************************************
|
|
|
|
```
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
systemd.services = {
|
|
|
|
woodpecker-server = {
|
|
|
|
description = "Woodpecker-Server Service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network-online.target" ];
|
|
|
|
wants = [ "network-online.target" ];
|
|
|
|
serviceConfig = {
|
|
|
|
DynamicUser = true;
|
|
|
|
WorkingDirectory = "%S/woodpecker-server";
|
|
|
|
StateDirectory = "woodpecker-server";
|
|
|
|
StateDirectoryMode = "0700";
|
|
|
|
UMask = "0007";
|
|
|
|
ConfigurationDirectory = "woodpecker-server";
|
2023-11-16 04:20:00 +00:00
|
|
|
EnvironmentFile = cfg.environmentFile;
|
2023-03-15 16:39:30 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/woodpecker-server";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = 15;
|
|
|
|
CapabilityBoundingSet = "";
|
|
|
|
# Security
|
|
|
|
NoNewPrivileges = true;
|
|
|
|
# Sandboxing
|
|
|
|
ProtectSystem = "strict";
|
|
|
|
ProtectHome = true;
|
|
|
|
PrivateTmp = true;
|
|
|
|
PrivateDevices = true;
|
|
|
|
PrivateUsers = true;
|
|
|
|
ProtectHostname = true;
|
|
|
|
ProtectClock = true;
|
|
|
|
ProtectKernelTunables = true;
|
|
|
|
ProtectKernelModules = true;
|
|
|
|
ProtectKernelLogs = true;
|
|
|
|
ProtectControlGroups = true;
|
|
|
|
RestrictAddressFamilies = [ "AF_UNIX AF_INET AF_INET6" ];
|
|
|
|
LockPersonality = true;
|
|
|
|
MemoryDenyWriteExecute = true;
|
|
|
|
RestrictRealtime = true;
|
|
|
|
RestrictSUIDSGID = true;
|
|
|
|
PrivateMounts = true;
|
|
|
|
# System Call Filtering
|
|
|
|
SystemCallArchitectures = "native";
|
|
|
|
SystemCallFilter = "~@clock @privileged @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io @reboot @setuid @swap";
|
|
|
|
};
|
|
|
|
inherit (cfg) environment;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|