Actions runner working

This commit is contained in:
Kat Huang 2024-08-18 12:22:08 -06:00
parent 12f673d13d
commit 4317b1fb3d
2 changed files with 31 additions and 37 deletions

View File

@ -30,37 +30,36 @@
networking.hostName = "mac-demarco-mini";
imports = [ (import ./gitea-actions-runner.nix) ];
services.gitea-actions-runner = {
user = "kat";
user = "gitearunner";
instances.nix = {
enable = true;
name = config.networking.hostName;
url = "https://dev.railbird.ai";
token = "kf8TgHEf2JwWiusV80ZWo3t7lkEyB1pVgqRdK5ES";
token = "H0A7YXAWsKSp9QzvMymfJI12hbxwR7UerEHpCJUe";
labels = [
"nix-darwin-${pkgs.system}:host"
"macos-aarch64-darwin"
"nix:host"
];
settings = {
cache = {
enabled = true;
};
container = {
workdir_parent = "/var/lib/gitea-runner/workspace";
};
host = {
workdir_parent = "/var/lib/gitea-runner/action-cache-dir";
};
};
hostPackages = with pkgs; [
bash
direnv
coreutils
curl
direnv
gawk
git-lfs
nixFlakes
gitFull
gnused
ncdu
nixFlakes
nodejs
openssh
wget
@ -68,14 +67,6 @@
};
};
# Create the necessary directories
system.activationScripts.giteaRunnerDirs = ''
mkdir -p /var/lib/gitea-runner/workspace
mkdir -p /var/lib/gitea-runner/action-cache-dir
chown -R kat:staff /var/lib/gitea-runner
'';
# Set environment variables
launchd.daemons.gitea-runner-nix.serviceConfig.EnvironmentVariables = {
XDG_CONFIG_HOME = "/var/lib/gitea-runner";
XDG_CACHE_HOME = "/var/lib/gitea-runner/.cache";
@ -89,6 +80,7 @@
gitFull
just
tmux
htop
nodePackages.prettier
nodejs
ripgrep
@ -120,9 +112,14 @@
# The platform the configuration will be used on.
nixpkgs.hostPlatform = "aarch64-darwin";
users.users.kat.openssh.authorizedKeys.keys = inputs.railbird-secrets.keys.kanivanKeys;
users.users.gitea-runner = {
name = "gitea-runner";
isHidden = false;
home = "/Users/gitea-runner";
createHome = false;
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.useGlobalPkgs = true; home-manager.useUserPackages = true;
users.users.kat = {
name = "kat";

View File

@ -32,12 +32,6 @@ in {
description = "The user account under which the Gitea Actions Runner should run.";
};
group = mkOption {
type = types.str;
default = "gitea-runner";
description = "The group under which the Gitea Actions Runner should run.";
};
instances = mkOption {
default = {};
description = "Gitea Actions Runner instances.";
@ -117,18 +111,22 @@ in {
description = "Gitea Actions Runner user";
};
users.groups.${cfg.group} = {};
launchd.daemons = mapAttrs' (name: instance:
nameValuePair "gitea-runner-${name}" {
serviceConfig = {
ProgramArguments = [
"${pkgs.writeShellScript "gitea-runner-start-${name}" ''
echo "home is $HOME"
mkdir -p /var/log/gitea-runner/
chown -R ${cfg.user} /var/log/gitea-runner
chmod 755 /var/log/gitea-runner
mkdir -p /var/lib/gitea-runner/${name}
chown -R ${cfg.user} /var/lib/gitea-runner
chmod 755 /var/lib/gitea-runner
sudo su - ${cfg.user}
export HOME="/var/lib/gitea-runner/${name}"
mkdir -p "$HOME"
cd "$HOME"
touch run_started
echo "STARTING"
# Register the runner if not already registered
if [ ! -e "$HOME/.runner" ]; then
@ -146,10 +144,10 @@ in {
];
KeepAlive = true;
RunAtLoad = true;
WorkingDirectory = "/var/lib/gitea-runner/${name}";
StandardOutPath = "/var/log/gitea-runner/${name}.log";
StandardErrorPath = "/var/log/gitea-runner/${name}.error.log";
SessionCreate = true;
UserName = cfg.user;
GroupName = "staff";
WorkingDirectory = "/var/lib/gitea-runner/${name}";
EnvironmentVariables = {
PATH = (lib.makeBinPath (instance.hostPackages ++ [ cfg.package ])) + ":/usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin";
} // optionalAttrs (instance.token != null) {
@ -161,15 +159,14 @@ in {
}
) cfg.instances;
# Ensure the log directory exists and has correct permissions
system.activationScripts.gitea-runner-setup = {
text = ''
mkdir -p /var/log/gitea-runner
chown ${cfg.user}:${cfg.group} /var/log/gitea-runner
mkdir -p /var/log/gitea-runner/
mkdir -p /var/lib/gitea-runner/${name}
chown -R ${cfg.user} /var/log/gitea-runner
chmod 755 /var/log/gitea-runner
mkdir -p /var/lib/gitea-runner
chown ${cfg.user}:${cfg.group} /var/lib/gitea-runner
chown -R ${cfg.user} /var/lib/gitea-runner
chmod 755 /var/lib/gitea-runner
'';
};