nixos/github-runner: use apply to override package

These changes allow users to reference the final package
This commit is contained in:
name_snrl
2025-07-26 03:13:24 +09:00
parent dd386adc75
commit 5d57f60991
2 changed files with 8 additions and 8 deletions

View File

@@ -26,7 +26,7 @@
default = { }; default = { };
type = lib.types.attrsOf ( type = lib.types.attrsOf (
lib.types.submodule ( lib.types.submodule (
{ name, ... }: { name, config, ... }:
{ {
options = { options = {
enable = lib.mkOption { enable = lib.mkOption {
@@ -186,7 +186,11 @@
default = { }; default = { };
}; };
package = lib.mkPackageOption pkgs "github-runner" { }; package = lib.mkPackageOption pkgs "github-runner" { } // {
apply =
# Support old github-runner versions which don't have the `nodeRuntimes` arg yet.
pkg: pkg.override (old: lib.optionalAttrs (old ? nodeRuntimes) { inherit (config) nodeRuntimes; });
};
ephemeral = lib.mkOption { ephemeral = lib.mkOption {
type = lib.types.bool; type = lib.types.bool;

View File

@@ -41,10 +41,6 @@
currentConfigTokenFilename = ".current-token"; currentConfigTokenFilename = ".current-token";
workDir = if cfg.workDir == null then runtimeDir else cfg.workDir; workDir = if cfg.workDir == null then runtimeDir else cfg.workDir;
# Support old github-runner versions which don't have the `nodeRuntimes` arg yet.
package = cfg.package.override (
old: lib.optionalAttrs (lib.hasAttr "nodeRuntimes" old) { inherit (cfg) nodeRuntimes; }
);
in in
lib.nameValuePair svcName { lib.nameValuePair svcName {
description = "GitHub Actions runner"; description = "GitHub Actions runner";
@@ -77,7 +73,7 @@
serviceConfig = lib.mkMerge [ serviceConfig = lib.mkMerge [
{ {
ExecStart = "${package}/bin/Runner.Listener run --startuptype service"; ExecStart = "${cfg.package}/bin/Runner.Listener run --startuptype service";
# Does the following, sequentially: # Does the following, sequentially:
# - If the module configuration or the token has changed, purge the state directory, # - If the module configuration or the token has changed, purge the state directory,
@@ -196,7 +192,7 @@
else else
args+=(--token "$token") args+=(--token "$token")
fi fi
${package}/bin/Runner.Listener configure "''${args[@]}" ${cfg.package}/bin/Runner.Listener configure "''${args[@]}"
# Move the automatically created _diag dir to the logs dir # Move the automatically created _diag dir to the logs dir
mkdir -p "$STATE_DIRECTORY/_diag" mkdir -p "$STATE_DIRECTORY/_diag"
cp -r "$STATE_DIRECTORY/_diag/." "$LOGS_DIRECTORY/" cp -r "$STATE_DIRECTORY/_diag/." "$LOGS_DIRECTORY/"