2023-08-01 16:57:22 +02:00
|
|
|
{ config, lib, ... }:
|
2023-03-18 12:51:12 +01:00
|
|
|
let
|
|
|
|
cfg = config.my.services.woodpecker;
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
|
|
services.woodpecker-server = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
environment = {
|
|
|
|
WOODPECKER_OPEN = "true";
|
|
|
|
WOODPECKER_HOST = "https://woodpecker.${config.networking.domain}";
|
|
|
|
WOODPECKER_DATABASE_DRIVER = "postgres";
|
|
|
|
WOODPECKER_DATABASE_DATASOURCE = "postgres:///woodpecker?host=/run/postgresql";
|
2023-11-06 21:54:40 +01:00
|
|
|
WOODPECKER_ADMIN = cfg.admin;
|
2023-03-18 12:51:12 +01:00
|
|
|
WOODPECKER_SERVER_ADDR = ":${toString cfg.port}";
|
|
|
|
WOODPECKER_GRPC_ADDR = ":${toString cfg.rpcPort}";
|
|
|
|
|
|
|
|
WOODPECKER_GITEA = "true";
|
2023-05-01 18:07:52 +02:00
|
|
|
WOODPECKER_GITEA_URL = config.services.gitea.settings.server.ROOT_URL;
|
2023-03-18 12:51:12 +01:00
|
|
|
|
|
|
|
WOODPECKER_LOG_LEVEL = "debug";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.woodpecker-server = {
|
2023-11-06 21:55:53 +01:00
|
|
|
after = [ "postgresql.service" ];
|
|
|
|
requires = [ "postgresql.service" ];
|
|
|
|
|
2023-03-18 12:51:12 +01:00
|
|
|
serviceConfig = {
|
|
|
|
# Set username for DB access
|
|
|
|
User = "woodpecker";
|
|
|
|
|
|
|
|
BindPaths = [
|
|
|
|
# Allow access to DB path
|
|
|
|
"/run/postgresql"
|
|
|
|
];
|
|
|
|
|
|
|
|
EnvironmentFile = [
|
|
|
|
cfg.secretFile
|
|
|
|
cfg.sharedSecretFile
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
services.postgresql = {
|
|
|
|
enable = true;
|
|
|
|
ensureDatabases = [ "woodpecker" ];
|
|
|
|
ensureUsers = [{
|
|
|
|
name = "woodpecker";
|
|
|
|
ensurePermissions = {
|
|
|
|
"DATABASE woodpecker" = "ALL PRIVILEGES";
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
};
|
|
|
|
|
|
|
|
my.services.nginx.virtualHosts = [
|
|
|
|
{
|
|
|
|
subdomain = "woodpecker";
|
|
|
|
inherit (cfg) port;
|
|
|
|
}
|
|
|
|
# I might want to be able to RPC from other hosts in the future
|
|
|
|
{
|
|
|
|
subdomain = "woodpecker-rpc";
|
|
|
|
port = cfg.rpcPort;
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
}
|