woodpecker things

This commit is contained in:
Anish Lakhwara 2022-12-23 16:16:19 +10:00
parent fc1f99b45f
commit 977c316049
2 changed files with 41 additions and 54 deletions

View file

@ -5,6 +5,7 @@
group = "woodpecker-runner"; group = "woodpecker-runner";
home = "/var/lib/woodpecker"; home = "/var/lib/woodpecker";
createHome = true; createHome = true;
extraGroups = [ "docker" ];
}; };
users.groups.woodpecker-runner = { }; users.groups.woodpecker-runner = { };
# Allow the exec runner to write to build with nix # Allow the exec runner to write to build with nix
@ -13,56 +14,43 @@
age.secrets.woodpecker-agent-secret.owner = "woodpecker-runner"; age.secrets.woodpecker-agent-secret.owner = "woodpecker-runner";
age.secrets.woodpecker-agent-secret.file = "${self}/secrets/woodpecker-agent-secret.age"; age.secrets.woodpecker-agent-secret.file = "${self}/secrets/woodpecker-agent-secret.age";
systemd.services.woodpecker-runner-exec = { systemd.services.woodpecker-agent = {
enable = true; enable = true;
wantedBy = [ "multi-user.target" ];
### MANUALLY RESTART SERVICE IF CHANGED ### MANUALLY RESTART SERVICE IF CHANGED
restartIfChanged = true; restartIfChanged = true;
confinement.enable = true; # confinement.enable = true;
confinement.packages = [ # confinement.packages = [
pkgs.git # pkgs.git
pkgs.gnutar # pkgs.gnutar
pkgs.bash # pkgs.bash
pkgs.nixFlakes # pkgs.nixFlakes
pkgs.gzip # pkgs.gzip
]; # ];
path = [ # path = [
pkgs.git # pkgs.git
pkgs.gnutar # pkgs.gnutar
pkgs.bash # pkgs.bash
pkgs.nixFlakes # pkgs.nixFlakes
pkgs.gzip # pkgs.gzip
]; # ];
serviceConfig = { serviceConfig = {
Type = "simple";
Environment = [ Environment = [
"WOODPECKER_RUNNER_CAPACITY=6" "WOODPECKER_RUNNER_CAPACITY=6"
"WOODPECKER_RUNNER_NAME=woodpecker-agent" # "WOODPECKER_RUNNER_NAME=woodpecker-agent"
"WOODPECKER_SERVER=https://ci.sealight.xyz/" "WOODPECKER_SERVER=https://ci.sealight.xyz/"
"WOODPECKER_HOSTNAME=mossnet" # "WOODPECKER_HOSTNAME=mossnet"
"WOODPECKER_BACKEND=local" # "WOODPECKER_BACKEND=local"
"NIX_REMOTE=daemon" # "NIX_REMOTE=daemon"
"PAGER=cat" # "PAGER=cat"
]; # "WOODPECKER_LOG_LEVEL=debug"
BindPaths = [
"/nix/var/nix/daemon-socket/socket"
"/run/nscd/socket"
"/var/lib/woodpecker"
"/var/empty/usr"
];
BindReadOnlyPaths = [
"/etc/passwd:/etc/passwd"
"/etc/group:/etc/group"
"/nix/var/nix/profiles/system/etc/nix:/etc/nix"
"${config.environment.etc."ssl/certs/ca-certificates.crt".source}:/etc/ssl/certs/ca-certificates.crt"
"${config.environment.etc."ssh/ssh_known_hosts".source}:/etc/ssh/ssh_known_hosts"
"${builtins.toFile "ssh_config" ''
Host git.sealight.xyz
ForwardAgent yes
''}:/etc/ssh/ssh_config"
"/etc/machine-id"
"/etc/resolv.conf"
"/nix/"
]; ];
WorkingDirectory = "/var/lib/woodpecker";
# Runtime directory and mode
RuntimeDirectory = "woodpecker";
RuntimeDirectoryMode = "0755";
# Access write directories
ReadWritePaths = [ "/var/lib/woodpecker" ];
EnvironmentFile = [ EnvironmentFile = [
/run/agenix/woodpecker-agent-secret /run/agenix/woodpecker-agent-secret
]; ];

View file

@ -1,4 +1,4 @@
{ self, ... }: { self, pkgs, config, ... }:
{ {
age.secrets.woodpecker-server-secrets.owner = "woodpecker"; age.secrets.woodpecker-server-secrets.owner = "woodpecker";
age.secrets.woodpecker-server-secrets.file = "${self}/secrets/woodpecker-server-secrets.age"; age.secrets.woodpecker-server-secrets.file = "${self}/secrets/woodpecker-server-secrets.age";
@ -10,6 +10,7 @@
description = "woodpecker user"; description = "woodpecker user";
home = "/var/lib/woodpecker"; home = "/var/lib/woodpecker";
createHome = true; createHome = true;
isNormalUser = true;
}; };
users.groups.woodpecker = { }; users.groups.woodpecker = { };
@ -17,9 +18,11 @@
services.nginx.virtualHosts."ci.sealight.xyz" = { services.nginx.virtualHosts."ci.sealight.xyz" = {
enableACME = true; enableACME = true;
forceSSL = true; forceSSL = true;
locations."/".proxyPass = "http://localhost:3030/"; locations."/".proxyPass = "http://localhost:38125";
}; };
networking.firewall.allowedTCPPorts = [ 80 443 22 ];
services.postgresql = { services.postgresql = {
ensureDatabases = [ "woodpecker" ]; ensureDatabases = [ "woodpecker" ];
ensureUsers = [{ ensureUsers = [{
@ -33,30 +36,26 @@
systemd.services.woodpecker-server = { systemd.services.woodpecker-server = {
wantedBy = [ "multi-user.target" ]; wantedBy = [ "multi-user.target" ];
serviceConfig = { serviceConfig = {
WorkingDirectory = "/var/lib/woodpecker";
EnvironmentFile = [ EnvironmentFile = [
/run/agenix/woodpecker-server-secrets /run/agenix/woodpecker-server-secrets
/run/agenix/woodpecker-agent-secret /run/agenix/woodpecker-agent-secret
]; ];
Environment = [ Environment = [
"WOODPECKER_OPEN=true" "WOODPECKER_OPEN=false"
"WOODPECKER_HOST=https://ci.sealight.xyz"
"WOODPECKER_SERVER_ADDR=:38125"
"WOODPECKER_GITEA=true" "WOODPECKER_GITEA=true"
"WOODPECKER_GITEA_URL=https://git.sealight.xyz" "WOODPECKER_GITEA_URL=https://git.sealight.xyz"
"WOODPECKER_DATABASE_DATASOURCE=postgres:///woodpecker?host=/run/postgresql" "WOODPECKER_DATABASE_DATASOURCE=postgres:///woodpecker?host=/run/postgresql"
"WOODPECKER_DATABASE_DRIVER=postgres" "WOODPECKER_DATABASE_DRIVER=postgres"
"WOODPECKER_SERVER_PORT=:3030"
"WOODPECKER_USER_CREATE=username:aynish,admin:true" # set your admin username "WOODPECKER_USER_CREATE=username:aynish,admin:true" # set your admin username
"${config.environment.etc."ssl/certs/ca-certificates.crt".source}:/etc/ssl/certs/ca-certificates.crt"
"${config.environment.etc."ssh/ssh_known_hosts".source}:/etc/ssh/ssh_known_hosts"
"${builtins.toFile "ssh_config" ''
Host git.sealight.xyz
ForwardAgent yes
''}:/etc/ssh/ssh_config"
]; ];
ExecStart = "${pkgs.woodpecker-server}/bin/woodpecker-server"; ExecStart = "${pkgs.woodpecker-server}/bin/woodpecker-server";
User = woodpecker; User = "woodpecker";
Group = woodpecker; Group = "woodpecker";
}; };
}; };