Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 bash, 5 buildGoModule, 6 fetchFromGitLab, 7 nix-update-script, 8 versionCheckHook, 9}: 10 11buildGoModule (finalAttrs: { 12 pname = "gitlab-runner"; 13 version = "18.1.2"; 14 15 src = fetchFromGitLab { 16 owner = "gitlab-org"; 17 repo = "gitlab-runner"; 18 tag = "v${finalAttrs.version}"; 19 hash = "sha256-zazDJBo6HiBh995nsYQvYCgcxyNaulV2ZrG7Kbwxb+0="; 20 }; 21 22 vendorHash = "sha256-G9qZKWI//ECG88Tu8zb8nEDSwNRabVMsrp7aQzVsxCY="; 23 24 # For patchShebangs 25 buildInputs = [ bash ]; 26 27 patches = [ 28 ./fix-shell-path.patch 29 ./remove-bash-test.patch 30 ]; 31 32 prePatch = '' 33 # Remove some tests that can't work during a nix build 34 35 # Needs the build directory to be a git repo 36 substituteInPlace commands/helpers/file_archiver_test.go \ 37 --replace-fail "func TestCacheArchiverAddingUntrackedFiles" "func OFF_TestCacheArchiverAddingUntrackedFiles" \ 38 --replace-fail "func TestCacheArchiverAddingUntrackedUnicodeFiles" "func OFF_TestCacheArchiverAddingUntrackedUnicodeFiles" 39 rm shells/abstract_test.go 40 41 # No writable developer environment 42 rm common/build_settings_test.go 43 rm common/build_test.go 44 rm executors/custom/custom_test.go 45 46 # No Docker during build 47 rm executors/docker/docker_test.go 48 rm executors/docker/services_test.go 49 rm executors/docker/terminal_test.go 50 rm helpers/docker/auth/auth_test.go 51 52 # No Kubernetes during build 53 rm executors/kubernetes/feature_test.go 54 rm executors/kubernetes/kubernetes_test.go 55 rm executors/kubernetes/overwrites_test.go 56 '' 57 + lib.optionalString stdenv.buildPlatform.isDarwin '' 58 # Invalid bind arguments break Unix socket tests 59 substituteInPlace commands/wrapper_test.go \ 60 --replace-fail "func TestRunnerWrapperCommand_createListener" "func OFF_TestRunnerWrapperCommand_createListener" 61 62 # No keychain access during build breaks X.509 certificate tests 63 substituteInPlace helpers/certificate/x509_test.go \ 64 --replace-fail "func TestCertificate" "func OFF_TestCertificate" 65 substituteInPlace network/client_test.go \ 66 --replace-fail "func TestClientInvalidSSL" "func OFF_TestClientInvalidSSL" 67 ''; 68 69 excludedPackages = [ 70 # Nested dependency Go module, used with go.mod replace directive 71 # 72 # https://gitlab.com/gitlab-org/gitlab-runner/-/commit/57ea9df5d8a8deb78c8d1972930bbeaa80d05e78 73 "./helpers/runner_wrapper/api" 74 # Helper scripts for upstream Make targets, not intended for downstream consumers 75 "./scripts" 76 ]; 77 78 ldflags = 79 let 80 ldflagsPackageVariablePrefix = "gitlab.com/gitlab-org/gitlab-runner/common"; 81 in 82 [ 83 "-X ${ldflagsPackageVariablePrefix}.NAME=gitlab-runner" 84 "-X ${ldflagsPackageVariablePrefix}.VERSION=${finalAttrs.version}" 85 "-X ${ldflagsPackageVariablePrefix}.REVISION=v${finalAttrs.version}" 86 ]; 87 88 preCheck = '' 89 # Make the tests pass outside of GitLab CI 90 export CI=0 91 ''; 92 93 # Many tests start servers which bind to ports 94 __darwinAllowLocalNetworking = true; 95 96 postInstall = '' 97 install packaging/root/usr/share/gitlab-runner/clear-docker-cache $out/bin 98 ''; 99 100 doInstallCheck = true; 101 102 nativeInstallCheckInputs = [ versionCheckHook ]; 103 104 versionCheckProgramArg = "--version"; 105 106 passthru = { 107 updateScript = nix-update-script { }; 108 }; 109 110 meta = { 111 description = "GitLab Runner the continuous integration executor of GitLab"; 112 homepage = "https://docs.gitlab.com/runner"; 113 license = lib.licenses.mit; 114 mainProgram = "gitlab-runner"; 115 maintainers = with lib.maintainers; [ zimbatm ]; 116 teams = [ lib.teams.gitlab ]; 117 }; 118})