1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-12-14 11:57:34 +00:00

github-runner: use lib.getExe{,'}

This commit is contained in:
Michael Hoang 2024-12-07 13:00:54 +11:00
parent d8255f09da
commit 06e1d77068

View file

@ -2,7 +2,7 @@
let let
inherit (lib) any attrValues boolToString concatStringsSep escapeShellArg inherit (lib) any attrValues boolToString concatStringsSep escapeShellArg
flatten flip getExe hasAttr hasPrefix mapAttrsToList mapAttrs' mkBefore flatten flip getExe getExe' hasAttr hasPrefix mapAttrsToList mapAttrs' mkBefore
mkDefault mkIf mkMerge nameValuePair optionalAttrs optionalString replaceStrings; mkDefault mkIf mkMerge nameValuePair optionalAttrs optionalString replaceStrings;
mkSvcName = name: "github-runner-${name}"; mkSvcName = name: "github-runner-${name}";
@ -55,15 +55,15 @@ in
( (
umask -S u=rwx,g=rx,o= > /dev/null umask -S u=rwx,g=rx,o= > /dev/null
${pkgs.coreutils}/bin/mkdir -p ${escapeShellArg (mkStateDir cfg)} ${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkStateDir cfg)}
${pkgs.coreutils}/bin/chown ${user}:${group} ${escapeShellArg (mkStateDir cfg)} ${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkStateDir cfg)}
${pkgs.coreutils}/bin/mkdir -p ${escapeShellArg (mkLogDir cfg)} ${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkLogDir cfg)}
${pkgs.coreutils}/bin/chown ${user}:${group} ${escapeShellArg (mkLogDir cfg)} ${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkLogDir cfg)}
${optionalString (cfg.workDir == null) '' ${optionalString (cfg.workDir == null) ''
${pkgs.coreutils}/bin/mkdir -p ${escapeShellArg (mkWorkDir cfg)} ${getExe' pkgs.coreutils "mkdir"} -p ${escapeShellArg (mkWorkDir cfg)}
${pkgs.coreutils}/bin/chown ${user}:${group} ${escapeShellArg (mkWorkDir cfg)} ${getExe' pkgs.coreutils "chown"} ${user}:${group} ${escapeShellArg (mkWorkDir cfg)}
''} ''}
) )
''); '');
@ -127,7 +127,7 @@ in
else else
args+=(--token "$token") args+=(--token "$token")
fi fi
${package}/bin/config.sh "''${args[@]}" ${getExe' package "config.sh"} "''${args[@]}"
''; '';
}; };
in in
@ -135,12 +135,12 @@ in
echo "Configuring GitHub Actions Runner" echo "Configuring GitHub Actions Runner"
# Always clean the working directory # Always clean the working directory
${pkgs.findutils}/bin/find ${escapeShellArg workDir} -mindepth 1 -delete ${getExe pkgs.findutils} ${escapeShellArg workDir} -mindepth 1 -delete
# Clean the $RUNNER_ROOT if we are in ephemeral mode # Clean the $RUNNER_ROOT if we are in ephemeral mode
if ${boolToString cfg.ephemeral}; then if ${boolToString cfg.ephemeral}; then
echo "Cleaning $RUNNER_ROOT" echo "Cleaning $RUNNER_ROOT"
${pkgs.findutils}/bin/find "$RUNNER_ROOT" -mindepth 1 -delete ${getExe pkgs.findutils} "$RUNNER_ROOT" -mindepth 1 -delete
fi fi
# If the `.runner` file does not exist, we assume the runner is not configured # If the `.runner` file does not exist, we assume the runner is not configured
@ -149,7 +149,7 @@ in
fi fi
# Start the service # Start the service
${package}/bin/Runner.Listener run --startuptype service ${getExe' package "Runner.Listener"} run --startuptype service
''; '';
serviceConfig = mkMerge [ serviceConfig = mkMerge [