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