Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 git, 6}: 7 8buildGoModule rec { 9 pname = "codecrafters-cli"; 10 version = "36"; 11 12 src = fetchFromGitHub { 13 owner = "codecrafters-io"; 14 repo = "cli"; 15 tag = "v${version}"; 16 hash = "sha256-YgQPDc5BUIoEd44NLpRluxCKooW99qvcSTrFPm6qJKM="; 17 # A shortened git commit hash is part of the version output, and is 18 # needed at build time. Use the `.git` directory to retrieve the 19 # commit SHA, and remove the directory afterwards since it is not needed 20 # after that. 21 leaveDotGit = true; 22 postFetch = '' 23 git -C $"$out" rev-parse --short=7 HEAD > $out/COMMIT 24 rm -rf $out/.git 25 ''; 26 }; 27 28 vendorHash = "sha256-5t/bRx3mT66e/efjWbb527ZdKOn3qV3hroqiLwP180g="; 29 30 ldflags = [ 31 "-s" 32 "-w" 33 "-X github.com/codecrafters-io/cli/internal/utils.Version=${version}" 34 ]; 35 36 # ldflags based on metadata from git 37 preBuild = '' 38 ldflags+=" -X github.com/codecrafters-io/cli/internal/utils.Commit=$(cat COMMIT)" 39 ''; 40 41 # We need to disable tests because the tests for respecting .gitignore 42 # include setting up a global gitignore which doesn't work. 43 doCheck = false; 44 45 nativeBuildInputs = [ git ]; 46 47 meta = with lib; { 48 description = "CodeCrafters CLI to run tests"; 49 mainProgram = "codecrafters"; 50 homepage = "https://github.com/codecrafters-io/cli"; 51 maintainers = with maintainers; [ builditluc ]; 52 license = licenses.mit; 53 }; 54}