python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / misc / fastly / default.nix
blob1c653327e717f2c426de7c1a594b118a274cf3aa
1 { lib, fetchurl, fetchFromGitHub, installShellFiles, buildGoModule, go }:
3 buildGoModule rec {
4   pname = "fastly";
5   version = "4.3.0";
7   src = fetchFromGitHub {
8     owner = "fastly";
9     repo = "cli";
10     rev = "v${version}";
11     sha256 = "sha256-TxN0DQ4OKfHn+u4ixpCgcyRRTs52IZRjgcbJuqajeVo=";
12     # The git commit is part of the `fastly version` original output;
13     # leave that output the same in nixpkgs. Use the `.git` directory
14     # to retrieve the commit SHA, and remove the directory afterwards,
15     # since it is not needed after that.
16     leaveDotGit = true;
17     postFetch = ''
18       cd "$out"
19       git rev-parse --short HEAD > $out/COMMIT
20       find "$out" -name .git -print0 | xargs -0 rm -rf
21     '';
22   };
24   subPackages = [ "cmd/fastly" ];
26   vendorSha256 = "sha256-7EtyQYPe+oJmQ7uECbjkBjLnM9T03g6gFwUwebKuccc=";
28   nativeBuildInputs = [ installShellFiles ];
30   # Flags as provided by the build automation of the project:
31   #   https://github.com/fastly/cli/blob/7844f9f54d56f8326962112b5534e5c40e91bf09/.goreleaser.yml#L14-L18
32   ldflags = [
33     "-s"
34     "-w"
35     "-X github.com/fastly/cli/pkg/revision.AppVersion=v${version}"
36     "-X github.com/fastly/cli/pkg/revision.Environment=release"
37     "-X github.com/fastly/cli/pkg/revision.GoHostOS=${go.GOHOSTOS}"
38     "-X github.com/fastly/cli/pkg/revision.GoHostArch=${go.GOHOSTARCH}"
39   ];
40   preBuild = let
41     cliConfigToml = fetchurl {
42       url = "https://web.archive.org/web/20221104122906/https://developer.fastly.com/api/internal/cli-config";
43       sha256 = "sha256-BHsUWrMp//X95gcB+WbD/nfyduZUkH8jHXk3CfOBAhg=";
44     };
45   in ''
46     cp ${cliConfigToml} ./pkg/config/config.toml
47     ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)"
48   '';
50   postInstall = ''
51     export HOME="$(mktemp -d)"
52     installShellCompletion --cmd fastly \
53       --bash <($out/bin/fastly --completion-script-bash) \
54       --zsh <($out/bin/fastly --completion-script-zsh)
55   '';
57   meta = with lib; {
58     description = "Command line tool for interacting with the Fastly API";
59     license = licenses.asl20;
60     homepage = "https://github.com/fastly/cli";
61     maintainers = with maintainers; [ ereslibre shyim ];
62   };