nixos/github-runner: use apply to override package (#428418)

Changed files
+8 -8
nixos
modules
services
continuous-integration
github-runner
+6 -2
nixos/modules/services/continuous-integration/github-runner/options.nix
···
default = { };
type = lib.types.attrsOf (
lib.types.submodule (
-
{ name, ... }:
+
{ name, config, ... }:
{
options = {
enable = lib.mkOption {
···
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 {
type = lib.types.bool;
+2 -6
nixos/modules/services/continuous-integration/github-runner/service.nix
···
currentConfigTokenFilename = ".current-token";
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
lib.nameValuePair svcName {
description = "GitHub Actions runner";
···
serviceConfig = lib.mkMerge [
{
-
ExecStart = "${package}/bin/Runner.Listener run --startuptype service";
+
ExecStart = "${cfg.package}/bin/Runner.Listener run --startuptype service";
# Does the following, sequentially:
# - If the module configuration or the token has changed, purge the state directory,
···
else
args+=(--token "$token")
fi
-
${package}/bin/Runner.Listener configure "''${args[@]}"
+
${cfg.package}/bin/Runner.Listener configure "''${args[@]}"
# Move the automatically created _diag dir to the logs dir
mkdir -p "$STATE_DIRECTORY/_diag"
cp -r "$STATE_DIRECTORY/_diag/." "$LOGS_DIRECTORY/"