Skip to content

Commit

Permalink
github-runner: use finalAttrs to make it possible to override the ver…
Browse files Browse the repository at this point in the history
…sion (#363733)

With rec, it is nearly impossible to override the version since it is
used in so many different places in the nix expression.
With the current change, it is possible to override version and src to
build a different version.

(cherry picked from commit d298dde)
  • Loading branch information
r-vdp authored and github-actions[bot] committed Dec 9, 2024
1 parent d75e74a commit 8e0d406
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions pkgs/by-name/gi/github-runner/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
# Node.js runtimes supported by upstream
assert builtins.all (x: builtins.elem x [ "node20" ]) nodeRuntimes;

buildDotnetModule rec {
buildDotnetModule (finalAttrs: {
pname = "github-runner";
version = "2.321.0";

src = fetchFromGitHub {
owner = "actions";
repo = "runner";
rev = "v${version}";
tag = "v${finalAttrs.version}";
hash = "sha256-KZ072v5kYlD78RGQl13Aj05DGzj2+r2akzyZ1aJn93A=";
leaveDotGit = true;
postFetch = ''
Expand All @@ -52,7 +52,7 @@ buildDotnetModule rec {
git config user.name "root"
git add .
git commit -m "Initial commit"
git checkout -b v${version}
git checkout -b v${finalAttrs.version}
)
mkdir -p $TMPDIR/bin
cat > $TMPDIR/bin/git <<EOF
Expand Down Expand Up @@ -95,7 +95,7 @@ buildDotnetModule rec {

DOTNET_SYSTEM_GLOBALIZATION_INVARIANT = isNull glibcLocales;
LOCALE_ARCHIVE = lib.optionalString (
!DOTNET_SYSTEM_GLOBALIZATION_INVARIANT
!finalAttrs.DOTNET_SYSTEM_GLOBALIZATION_INVARIANT
) "${glibcLocales}/lib/locale/locale-archive";

postConfigure = ''
Expand All @@ -105,7 +105,7 @@ buildDotnetModule rec {
-p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \
-p:PackageRuntime="${dotnetCorePackages.systemToDotnetRid stdenv.hostPlatform.system}" \
-p:RunnerVersion="${version}" \
-p:RunnerVersion="${finalAttrs.version}" \
src/dir.proj
'';

Expand Down Expand Up @@ -204,7 +204,7 @@ buildDotnetModule rec {
"GitHub.Runner.Common.Tests.Worker.StepHostL0.DetermineNodeRuntimeVersionInAlpineContainerAsync"
"GitHub.Runner.Common.Tests.Worker.StepHostL0.DetermineNode20RuntimeVersionInAlpineContainerAsync"
]
++ lib.optionals DOTNET_SYSTEM_GLOBALIZATION_INVARIANT [
++ lib.optionals finalAttrs.DOTNET_SYSTEM_GLOBALIZATION_INVARIANT [
"GitHub.Runner.Common.Tests.ProcessExtensionL0.SuccessReadProcessEnv"
"GitHub.Runner.Common.Tests.Util.StringUtilL0.FormatUsesInvariantCulture"
"GitHub.Runner.Common.Tests.Worker.VariablesL0.Constructor_SetsOrdinalIgnoreCaseComparer"
Expand Down Expand Up @@ -243,7 +243,7 @@ buildDotnetModule rec {
+ lib.optionalString stdenv.hostPlatform.isLinux ''
substituteInPlace $out/lib/github-runner/config.sh \
--replace 'command -v ldd' 'command -v ${glibc.bin}/bin/ldd' \
--replace 'ldd ./bin' '${glibc.bin}/bin/ldd ${dotnet-runtime}/share/dotnet/shared/Microsoft.NETCore.App/${dotnet-runtime.version}/' \
--replace 'ldd ./bin' '${glibc.bin}/bin/ldd ${finalAttrs.dotnet-runtime}/share/dotnet/shared/Microsoft.NETCore.App/${finalAttrs.dotnet-runtime.version}/' \
--replace '/sbin/ldconfig' '${glibc.bin}/bin/ldconfig'
''
+ ''
Expand Down Expand Up @@ -309,7 +309,7 @@ buildDotnetModule rec {
$out/bin/Runner.Listener --help >/dev/null
version=$($out/bin/Runner.Listener --version)
if [[ "$version" != "${version}" ]]; then
if [[ "$version" != "${finalAttrs.version}" ]]; then
printf 'Unexpected version %s' "$version"
exit 1
fi
Expand Down Expand Up @@ -347,4 +347,4 @@ buildDotnetModule rec {
];
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
};
}
})

0 comments on commit 8e0d406

Please sign in to comment.