Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 fetchurl, 4 fetchFromGitHub, 5 installShellFiles, 6 buildGoModule, 7 go, 8 makeWrapper, 9 viceroy, 10}: 11 12buildGoModule rec { 13 pname = "fastly"; 14 version = "11.4.0"; 15 16 src = fetchFromGitHub { 17 owner = "fastly"; 18 repo = "cli"; 19 tag = "v${version}"; 20 hash = "sha256-jfj37b3L3LcPODBYBAOTWq+mA0xrIr3r+6lu65gKyYI="; 21 # The git commit is part of the `fastly version` original output; 22 # leave that output the same in nixpkgs. Use the `.git` directory 23 # to retrieve the commit SHA, and remove the directory afterwards, 24 # since it is not needed after that. 25 leaveDotGit = true; 26 postFetch = '' 27 cd "$out" 28 git rev-parse --short HEAD > $out/COMMIT 29 find "$out" -name .git -print0 | xargs -0 rm -rf 30 ''; 31 }; 32 33 subPackages = [ 34 "cmd/fastly" 35 ]; 36 37 vendorHash = "sha256-souo+yksoZpUxWfY7flL4uLdRgAIrtZKRIlGK0p1hZs="; 38 39 nativeBuildInputs = [ 40 installShellFiles 41 makeWrapper 42 ]; 43 44 # Flags as provided by the build automation of the project: 45 # https://github.com/fastly/cli/blob/7844f9f54d56f8326962112b5534e5c40e91bf09/.goreleaser.yml#L14-L18 46 ldflags = [ 47 "-s" 48 "-w" 49 "-X github.com/fastly/cli/pkg/revision.AppVersion=v${version}" 50 "-X github.com/fastly/cli/pkg/revision.Environment=release" 51 "-X github.com/fastly/cli/pkg/revision.GoHostOS=${go.GOHOSTOS}" 52 "-X github.com/fastly/cli/pkg/revision.GoHostArch=${go.GOHOSTARCH}" 53 ]; 54 preBuild = 55 let 56 cliConfigToml = fetchurl { 57 url = "https://web.archive.org/web/20240910172801/https://developer.fastly.com/api/internal/cli-config"; 58 hash = "sha256-r4ahroyU4hyTN88UK02FvXU8OTQ6OoNInt9WrzZk7Bk="; 59 }; 60 in 61 '' 62 cp ${cliConfigToml} ./pkg/config/config.toml 63 ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)" 64 ''; 65 66 preFixup = '' 67 wrapProgram $out/bin/fastly --prefix PATH : ${lib.makeBinPath [ viceroy ]} \ 68 --set FASTLY_VICEROY_USE_PATH 1 69 ''; 70 71 postInstall = '' 72 export HOME="$(mktemp -d)" 73 installShellCompletion --cmd fastly \ 74 --bash <($out/bin/fastly --completion-script-bash) \ 75 --zsh <($out/bin/fastly --completion-script-zsh) 76 ''; 77 78 meta = with lib; { 79 description = "Command line tool for interacting with the Fastly API"; 80 homepage = "https://github.com/fastly/cli"; 81 changelog = "https://github.com/fastly/cli/blob/v${version}/CHANGELOG.md"; 82 license = licenses.asl20; 83 maintainers = with maintainers; [ 84 ereslibre 85 shyim 86 ]; 87 mainProgram = "fastly"; 88 }; 89}