1{ autoPatchelfHook 2, coreutils 3, curl 4, dotnetCorePackages 5, dotnetPackages 6, fetchFromGitHub 7, fetchurl 8, git 9, glibc 10, icu 11, libkrb5 12, lib 13, linkFarm 14, lttng-ust 15, makeWrapper 16, nodejs-12_x 17, openssl 18, stdenv 19, zlib 20}: 21let 22 deps = (import ./deps.nix { inherit fetchurl; }); 23 nugetPackages = map 24 (x: { 25 name = "${x.name}.nupkg"; 26 path = "${x}"; 27 }) 28 deps; 29 nugetSource = linkFarm "nuget-packages" nugetPackages; 30 31 dotnetSdk = dotnetCorePackages.sdk_3_1; 32 runtimeId = 33 if stdenv.isAarch64 34 then "linux-arm64" 35 else "linux-x64"; 36 fakeSha1 = "0000000000000000000000000000000000000000"; 37in 38stdenv.mkDerivation rec { 39 pname = "github-runner"; 40 version = "2.284.0"; 41 42 src = fetchFromGitHub { 43 owner = "actions"; 44 repo = "runner"; 45 rev = "v${version}"; 46 sha256 = "sha256-JR0OzbT5gGhO/dxb/eSjP/d/VxW/aLmTs/oPwN8b8Rc="; 47 }; 48 49 nativeBuildInputs = [ 50 dotnetSdk 51 dotnetPackages.Nuget 52 makeWrapper 53 autoPatchelfHook 54 ]; 55 56 buildInputs = [ 57 curl # libcurl.so.4 58 libkrb5 # libgssapi_krb5.so.2 59 lttng-ust # liblttng-ust.so.0 60 stdenv.cc.cc.lib # libstdc++.so.6 61 zlib # libz.so.1 62 icu 63 ]; 64 65 patches = [ 66 # Don't run Git, no restore on build/test 67 ./patches/dir-proj.patch 68 # Replace some paths that originally point to Nix's read-only store 69 ./patches/host-context-dirs.patch 70 # Use GetDirectory() to obtain "diag" dir 71 ./patches/use-get-directory-for-diag.patch 72 # Don't try to install systemd service 73 ./patches/dont-install-systemd-service.patch 74 # Prevent the runner from starting a self-update for new versions 75 # (upstream issue: https://github.com/actions/runner/issues/485) 76 ./patches/prevent-self-update.patch 77 ]; 78 79 postPatch = '' 80 # Relax the version requirement 81 substituteInPlace src/global.json \ 82 --replace '3.1.302' '${dotnetSdk.version}' 83 84 # Disable specific tests 85 substituteInPlace src/dir.proj \ 86 --replace 'dotnet test Test/Test.csproj' \ 87 "dotnet test Test/Test.csproj --filter '${lib.concatStringsSep "&" disabledTests}'" 88 89 # We don't use a Git checkout 90 substituteInPlace src/dir.proj \ 91 --replace 'git update-index --assume-unchanged ./Runner.Sdk/BuildConstants.cs' \ 92 'echo Patched out.' 93 94 # Fix FHS path 95 substituteInPlace src/Test/L0/Util/IOUtilL0.cs \ 96 --replace '/bin/ln' '${coreutils}/bin/ln' 97 ''; 98 99 configurePhase = '' 100 runHook preConfigure 101 102 # Set up Nuget dependencies 103 export HOME=$(mktemp -d) 104 export DOTNET_CLI_TELEMETRY_OPTOUT=1 105 export DOTNET_NOLOGO=1 106 107 # Never use nuget.org 108 nuget sources Disable -Name "nuget.org" 109 110 # Restore the dependencies 111 dotnet restore src/ActionsRunner.sln \ 112 --runtime "${runtimeId}" \ 113 --source "${nugetSource}" 114 115 runHook postConfigure 116 ''; 117 118 postConfigure = '' 119 # `crossgen` dependency is called during build 120 patchelf \ 121 --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \ 122 --set-rpath "${lib.makeLibraryPath [ stdenv.cc.cc.lib ]}" \ 123 $HOME/.nuget/packages/microsoft.netcore.app.runtime.${runtimeId}/*/tools/crossgen 124 ''; 125 126 buildPhase = '' 127 runHook preBuild 128 129 dotnet msbuild \ 130 -t:Build \ 131 -p:PackageRuntime="${runtimeId}" \ 132 -p:BUILDCONFIG="Release" \ 133 -p:RunnerVersion="${version}" \ 134 -p:GitInfoCommitHash="${fakeSha1}" \ 135 src/dir.proj 136 137 runHook postBuild 138 ''; 139 140 doCheck = true; 141 142 disabledTests = [ 143 # Self-updating is patched out, hence this test will fail 144 "FullyQualifiedName!=GitHub.Runner.Common.Tests.Listener.RunnerL0.TestRunOnceHandleUpdateMessage" 145 ] ++ map 146 # Online tests 147 (x: "FullyQualifiedName!=GitHub.Runner.Common.Tests.Worker.ActionManagerL0.PrepareActions_${x}") 148 [ 149 "CompositeActionWithActionfile_CompositeContainerNested" 150 "CompositeActionWithActionfile_CompositePrestepNested" 151 "CompositeActionWithActionfile_MaxLimit" 152 "CompositeActionWithActionfile_Node" 153 "DownloadActionFromGraph" 154 "DownloadActionFromGraph_Legacy" 155 "NotPullOrBuildImagesMultipleTimes" 156 "NotPullOrBuildImagesMultipleTimes_Legacy" 157 "RepositoryActionWithActionYamlFile_DockerHubImage" 158 "RepositoryActionWithActionYamlFile_DockerHubImage_Legacy" 159 "RepositoryActionWithActionfileAndDockerfile" 160 "RepositoryActionWithActionfileAndDockerfile_Legacy" 161 "RepositoryActionWithActionfile_DockerHubImage" 162 "RepositoryActionWithActionfile_DockerHubImage_Legacy" 163 "RepositoryActionWithActionfile_Dockerfile" 164 "RepositoryActionWithActionfile_Dockerfile_Legacy" 165 "RepositoryActionWithActionfile_DockerfileRelativePath" 166 "RepositoryActionWithActionfile_DockerfileRelativePath_Legacy" 167 "RepositoryActionWithActionfile_Node" 168 "RepositoryActionWithActionfile_Node_Legacy" 169 "RepositoryActionWithDockerfile" 170 "RepositoryActionWithDockerfile_Legacy" 171 "RepositoryActionWithDockerfileInRelativePath" 172 "RepositoryActionWithDockerfileInRelativePath_Legacy" 173 "RepositoryActionWithDockerfilePrepareActions_Repository" 174 "RepositoryActionWithInvalidWrapperActionfile_Node" 175 "RepositoryActionWithInvalidWrapperActionfile_Node_Legacy" 176 "RepositoryActionWithWrapperActionfile_PreSteps" 177 "RepositoryActionWithWrapperActionfile_PreSteps_Legacy" 178 ] ++ map 179 (x: "FullyQualifiedName!=GitHub.Runner.Common.Tests.DotnetsdkDownloadScriptL0.${x}") 180 [ 181 "EnsureDotnetsdkBashDownloadScriptUpToDate" 182 "EnsureDotnetsdkPowershellDownloadScriptUpToDate" 183 ]; 184 185 checkInputs = [ git ]; 186 187 checkPhase = '' 188 runHook preCheck 189 190 mkdir -p _layout/externals 191 ln -s ${nodejs-12_x} _layout/externals/node12 192 193 # BUILDCONFIG needs to be "Debug" 194 dotnet msbuild \ 195 -t:test \ 196 -p:PackageRuntime="${runtimeId}" \ 197 -p:BUILDCONFIG="Debug" \ 198 -p:RunnerVersion="${version}" \ 199 -p:GitInfoCommitHash="${fakeSha1}" \ 200 src/dir.proj 201 202 runHook postCheck 203 ''; 204 205 installPhase = '' 206 runHook preInstall 207 208 # Copy the built binaries to lib/ instead of bin/ as they 209 # have to be wrapped in the fixup phase to work 210 mkdir -p $out/lib 211 cp -r _layout/bin/. $out/lib/ 212 213 # Delete debugging files 214 find "$out/lib" -type f -name '*.pdb' -delete 215 216 # Install the helper scripts to bin/ to resemble the upstream package 217 mkdir -p $out/bin 218 install -m755 src/Misc/layoutbin/runsvc.sh $out/bin/ 219 install -m755 src/Misc/layoutbin/RunnerService.js $out/lib/ 220 install -m755 src/Misc/layoutroot/run.sh $out/lib/ 221 install -m755 src/Misc/layoutroot/config.sh $out/lib/ 222 install -m755 src/Misc/layoutroot/env.sh $out/lib/ 223 224 # Rewrite reference in helper scripts from bin/ to lib/ 225 substituteInPlace $out/lib/run.sh --replace '"$DIR"/bin' "$out/lib" 226 substituteInPlace $out/lib/config.sh --replace './bin' "$out/lib" 227 228 # Make paths absolute 229 substituteInPlace $out/bin/runsvc.sh \ 230 --replace './externals' "$out/externals" \ 231 --replace './bin' "$out/lib" 232 233 # The upstream package includes Node 12 and expects it at the path 234 # externals/node12. As opposed to the official releases, we don't 235 # link the Alpine Node flavor. 236 mkdir -p $out/externals 237 ln -s ${nodejs-12_x} $out/externals/node12 238 239 runHook postInstall 240 ''; 241 242 # Stripping breaks the binaries 243 dontStrip = true; 244 245 preFixup = '' 246 patchelf --replace-needed liblttng-ust.so.0 liblttng-ust.so $out/lib/libcoreclrtraceptprovider.so 247 ''; 248 249 postFixup = '' 250 fix_rpath() { 251 patchelf --set-interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" $out/lib/$1 252 } 253 254 wrap() { 255 makeWrapper $out/lib/$1 $out/bin/$1 \ 256 --prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath (buildInputs ++ [ openssl ])} \ 257 ''${@:2} 258 } 259 260 fix_rpath Runner.Listener 261 fix_rpath Runner.PluginHost 262 fix_rpath Runner.Worker 263 264 wrap Runner.Listener 265 wrap Runner.PluginHost 266 wrap Runner.Worker 267 wrap run.sh 268 wrap env.sh 269 270 wrap config.sh --prefix PATH : ${lib.makeBinPath [ glibc.bin ]} 271 ''; 272 273 meta = with lib; { 274 description = "Self-hosted runner for GitHub Actions"; 275 homepage = "https://github.com/actions/runner"; 276 license = licenses.mit; 277 maintainers = with maintainers; [ veehaitch newam ]; 278 platforms = [ "x86_64-linux" "aarch64-linux" ]; 279 }; 280}