Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at python-updates 86 lines 2.1 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 git, 6 testers, 7 makeWrapper, 8 githooks, 9}: 10buildGoModule rec { 11 pname = "githooks"; 12 version = "3.0.4"; 13 14 src = fetchFromGitHub { 15 owner = "gabyx"; 16 repo = "githooks"; 17 rev = "v${version}"; 18 hash = "sha256-pTSC8ruNiPzQO1C6j+G+WFX3pz/mWPukuWkKUSYdfHw="; 19 }; 20 21 modRoot = "./githooks"; 22 vendorHash = "sha256-ZcDD4Z/thtyCvXg6GzzKC/FSbh700QEaqXU8FaZaZc4="; 23 24 nativeBuildInputs = [ makeWrapper ]; 25 26 buildInputs = [ git ]; 27 28 strictDeps = true; 29 30 ldflags = [ 31 "-s" # Disable symbole table. 32 "-w" # Disable DWARF generation. 33 ]; 34 35 # We need to disable updates and other features: 36 # That is done with tag `package_manager_enabled`. 37 tags = [ "package_manager_enabled" ]; 38 39 checkFlags = 40 let 41 skippedTests = [ 42 "TestGithooksCompliesWithGit" # Needs internet to download all hooks documentation. 43 "TestUpdateImages" # Needs docker/podman. 44 ]; 45 in 46 [ 47 "-v" 48 "-skip" 49 "(${builtins.concatStringsSep "|" skippedTests})" 50 ]; 51 52 doCheck = true; 53 54 # We need to generate some build files before building. 55 postConfigure = '' 56 GH_BUILD_VERSION="${version}" \ 57 GH_BUILD_TAG="v${version}" \ 58 go generate -mod=vendor ./... 59 ''; 60 61 postInstall = '' 62 # Rename executable to proper names. 63 mv $out/bin/cli $out/bin/githooks-cli 64 mv $out/bin/runner $out/bin/githooks-runner 65 mv $out/bin/dialog $out/bin/githooks-dialog 66 ''; 67 68 postFixup = '' 69 wrapProgram "$out/bin/githooks-cli" --prefix PATH : ${lib.makeBinPath [ git ]} 70 wrapProgram "$out/bin/githooks-runner" --prefix PATH : ${lib.makeBinPath [ git ]} 71 ''; 72 73 passthru.tests.version = testers.testVersion { 74 package = githooks; 75 command = "githooks-cli --version"; 76 inherit version; 77 }; 78 79 meta = with lib; { 80 description = "Git hooks manager with per-repo and shared Git hooks including version control"; 81 homepage = "https://github.com/gabyx/Githooks"; 82 license = licenses.mpl20; 83 maintainers = with maintainers; [ gabyx ]; 84 mainProgram = "githooks-cli"; 85 }; 86}