Actions runner runs as kat

This commit is contained in:
Kat Huang 2024-08-15 03:49:52 -06:00
parent b863346787
commit 12f673d13d
2 changed files with 3 additions and 5 deletions

View File

@ -30,6 +30,7 @@
networking.hostName = "mac-demarco-mini"; networking.hostName = "mac-demarco-mini";
imports = [ (import ./gitea-actions-runner.nix) ]; imports = [ (import ./gitea-actions-runner.nix) ];
services.gitea-actions-runner = { services.gitea-actions-runner = {
user = "kat";
instances.nix = { instances.nix = {
enable = true; enable = true;
name = config.networking.hostName; name = config.networking.hostName;

View File

@ -112,11 +112,8 @@ in {
} }
]; ];
# Create the user and group
users.users.${cfg.user} = { users.users.${cfg.user} = {
name = cfg.user; name = cfg.user;
home = "/var/lib/gitea-runner";
createHome = true;
description = "Gitea Actions Runner user"; description = "Gitea Actions Runner user";
}; };
@ -127,6 +124,7 @@ in {
serviceConfig = { serviceConfig = {
ProgramArguments = [ ProgramArguments = [
"${pkgs.writeShellScript "gitea-runner-start-${name}" '' "${pkgs.writeShellScript "gitea-runner-start-${name}" ''
sudo su - ${cfg.user}
export HOME="/var/lib/gitea-runner/${name}" export HOME="/var/lib/gitea-runner/${name}"
mkdir -p "$HOME" mkdir -p "$HOME"
cd "$HOME" cd "$HOME"
@ -144,7 +142,7 @@ in {
# Start the runner # Start the runner
exec ${cfg.package}/bin/act_runner daemon --config ${settingsFormat.generate "config.yaml" instance.settings} exec ${cfg.package}/bin/act_runner daemon --config ${settingsFormat.generate "config.yaml" instance.settings}
'' ''}"
]; ];
KeepAlive = true; KeepAlive = true;
RunAtLoad = true; RunAtLoad = true;
@ -152,7 +150,6 @@ in {
StandardOutPath = "/var/log/gitea-runner/${name}.log"; StandardOutPath = "/var/log/gitea-runner/${name}.log";
StandardErrorPath = "/var/log/gitea-runner/${name}.error.log"; StandardErrorPath = "/var/log/gitea-runner/${name}.error.log";
UserName = cfg.user; UserName = cfg.user;
GroupName = cfg.group;
EnvironmentVariables = { EnvironmentVariables = {
PATH = (lib.makeBinPath (instance.hostPackages ++ [ cfg.package ])) + ":/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin"; PATH = (lib.makeBinPath (instance.hostPackages ++ [ cfg.package ])) + ":/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin";
} // optionalAttrs (instance.token != null) { } // optionalAttrs (instance.token != null) {