2022-12-19 09:09:08 +00:00
|
|
|
{
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
inputs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: let
|
2022-11-08 13:46:08 +00:00
|
|
|
httpPort = 8000;
|
2022-11-08 16:13:33 +00:00
|
|
|
agentPort = 9000;
|
2022-11-08 13:46:08 +00:00
|
|
|
domain = "ci.cyplo.dev";
|
2022-12-02 21:34:38 +00:00
|
|
|
path = "/var/lib/woodpecker";
|
2022-11-08 19:19:25 +00:00
|
|
|
serverContainerName = "woodpecker-server";
|
2022-12-21 12:54:55 +00:00
|
|
|
uid = 2061;
|
|
|
|
gid = 3061;
|
|
|
|
systemUserName = "woodpecker";
|
|
|
|
systemGroupName = "woodpecker";
|
|
|
|
podmanGid = 994;
|
|
|
|
secretSettings = {
|
|
|
|
owner = systemUserName;
|
|
|
|
group = systemGroupName;
|
2022-12-04 13:46:47 +00:00
|
|
|
};
|
2022-12-21 12:54:55 +00:00
|
|
|
woodpeckerEnvSecretName = "woodpecker-env";
|
|
|
|
woodpeckerEnvSecretPath = "/run/secrets/${woodpeckerEnvSecretName}";
|
2022-11-08 16:13:33 +00:00
|
|
|
in {
|
2022-12-19 09:09:08 +00:00
|
|
|
imports = [../nginx.nix];
|
2022-11-08 13:46:08 +00:00
|
|
|
|
2022-12-21 12:54:55 +00:00
|
|
|
users = {
|
|
|
|
users."${systemUserName}" = {
|
|
|
|
inherit uid;
|
|
|
|
isSystemUser = true;
|
|
|
|
isNormalUser = false;
|
|
|
|
group = systemGroupName;
|
|
|
|
extraGroups = ["podman"];
|
|
|
|
};
|
|
|
|
groups."${systemGroupName}" = {
|
|
|
|
inherit gid;
|
|
|
|
members = ["${systemUserName}"];
|
|
|
|
};
|
|
|
|
groups."podman" = {
|
|
|
|
gid = podmanGid;
|
|
|
|
members = ["${systemUserName}"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-11-08 13:46:08 +00:00
|
|
|
services.nginx = {
|
|
|
|
virtualHosts = {
|
|
|
|
"${domain}" = {
|
|
|
|
forceSSL = true;
|
|
|
|
enableACME = true;
|
|
|
|
locations."/" = {
|
|
|
|
proxyPass = "http://localhost:" + toString httpPort;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
sops.secrets."gitea-env" = {
|
|
|
|
sopsFile = ./gitea.sops;
|
|
|
|
format = "binary";
|
|
|
|
};
|
|
|
|
|
2022-12-21 12:54:55 +00:00
|
|
|
sops.secrets."woodpecker-env" =
|
|
|
|
{
|
|
|
|
sopsFile = ./gitea.sops;
|
|
|
|
format = "binary";
|
|
|
|
path = woodpeckerEnvSecretPath;
|
|
|
|
}
|
|
|
|
// secretSettings;
|
|
|
|
|
|
|
|
virtualisation.podman = {
|
|
|
|
enable = true;
|
|
|
|
defaultNetwork.dnsname.enable = true;
|
|
|
|
};
|
|
|
|
networking.firewall.allowedTCPPorts = [agentPort];
|
2022-12-04 13:46:47 +00:00
|
|
|
virtualisation.oci-containers.containers = {
|
|
|
|
"${serverContainerName}" = {
|
2022-12-19 09:09:08 +00:00
|
|
|
image = "woodpeckerci/woodpecker-server@sha256:e6027e46a782d50790183b7274a2a2ad3a6c6fb9a645e6af81a16419613c28ea";
|
|
|
|
volumes = ["woodpecker-server-data:${path}"];
|
|
|
|
environmentFiles = ["${config.sops.secrets.gitea-env.path}"];
|
2022-12-04 13:46:47 +00:00
|
|
|
environment = {
|
|
|
|
WOODPECKER_OPEN = "false";
|
|
|
|
WOODPECKER_ADMIN = "cyplo";
|
|
|
|
WOODPECKER_HOST = "https://${domain}";
|
|
|
|
WOODPECKER_GITEA = "true";
|
|
|
|
WOODPECKER_GITEA_URL = "https://git.cyplo.dev";
|
|
|
|
};
|
2022-12-21 12:54:55 +00:00
|
|
|
ports = [
|
|
|
|
"${toString httpPort}:${toString httpPort}"
|
|
|
|
"${toString agentPort}:${toString agentPort}"
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
containers.woodpecker-agent1 = {
|
|
|
|
autoStart = true;
|
|
|
|
forwardPorts = [
|
|
|
|
];
|
|
|
|
bindMounts = {
|
|
|
|
"${woodpeckerEnvSecretPath}" = {
|
|
|
|
hostPath = "${woodpeckerEnvSecretPath}";
|
|
|
|
isReadOnly = true;
|
|
|
|
};
|
|
|
|
"/var/run/docker.sock" = {
|
|
|
|
hostPath = "/var/run/podman/podman.sock";
|
|
|
|
isReadOnly = false;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
config = {
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
system.stateVersion = "22.11";
|
|
|
|
users = {
|
|
|
|
mutableUsers = false;
|
|
|
|
allowNoPasswordLogin = true;
|
|
|
|
users."${systemUserName}" = {
|
|
|
|
inherit uid;
|
|
|
|
isSystemUser = true;
|
|
|
|
isNormalUser = false;
|
|
|
|
group = systemGroupName;
|
|
|
|
};
|
|
|
|
groups."${systemGroupName}" = {
|
|
|
|
inherit gid;
|
|
|
|
members = ["${systemUserName}"];
|
|
|
|
};
|
|
|
|
groups."podman" = {
|
|
|
|
gid = podmanGid;
|
|
|
|
members = ["${systemUserName}"];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.woodpecker-agent = {
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
environment = {
|
|
|
|
WOODPECKER_SERVER = "${domain}:${toString agentPort}";
|
|
|
|
WOODPECKER_MAX_PROCS = "1";
|
|
|
|
WOODPECKER_DEBUG_PRETTY = "true";
|
|
|
|
WOODPECKER_LOG_LEVEL = "info";
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
EnvironmentFile = [
|
|
|
|
woodpeckerEnvSecretPath
|
|
|
|
];
|
|
|
|
ExecStart = "${pkgs.woodpecker-agent}/bin/woodpecker-agent";
|
|
|
|
User = systemUserName;
|
|
|
|
Group = systemGroupName;
|
|
|
|
};
|
|
|
|
};
|
2022-11-08 13:46:08 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|