diff --git a/pkgs/development/tools/continuous-integration/github-runner/default.nix b/pkgs/development/tools/continuous-integration/github-runner/default.nix index b976757da00a..7e0fefb70b8e 100644 --- a/pkgs/development/tools/continuous-integration/github-runner/default.nix +++ b/pkgs/development/tools/continuous-integration/github-runner/default.nix @@ -12,6 +12,8 @@ , nodejs_16 , stdenv , which +, buildPackages +, runtimeShell }: buildDotnetModule rec { pname = "github-runner"; @@ -21,11 +23,41 @@ buildDotnetModule rec { owner = "actions"; repo = "runner"; rev = "v${version}"; - hash = "sha256-w5MqFIPTCAqQjdsWdscNnH2KNwUOp5SPFesyprXUvNE="; - # Required to obtain HEAD's Git commit hash + hash = "sha256-5amc0oVcFCPFrUcX5iITjnN9Mtpzi4wWsJe7Kdm9YxA="; leaveDotGit = true; + postFetch = '' + git -C $out rev-parse --short HEAD > $out/.git-revision + rm -rf $out/.git + ''; }; + # The git commit is read during the build and some tests depends on a git repo to be present + # https://github.com/actions/runner/blob/22d1938ac420a4cb9e3255e47a91c2e43c38db29/src/dir.proj#L5 + unpackPhase = '' + cp -r $src $TMPDIR/src + chmod -R +w $TMPDIR/src + cd $TMPDIR/src + ( + export PATH=${buildPackages.git}/bin:$PATH + git init + git config user.email "root@localhost" + git config user.name "root" + git add . + git commit -m "Initial commit" + git checkout -b v${version} + ) + mkdir -p $TMPDIR/bin + cat > $TMPDIR/bin/git <