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