2022-10-21 15:01:26 +00:00
|
|
|
{ lib, fetchurl, fetchFromGitHub, installShellFiles, buildGoModule, go }:
|
2022-04-24 09:50:16 +00:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "fastly";
|
2022-12-04 02:38:28 +00:00
|
|
|
version = "4.4.1";
|
2022-04-24 09:50:16 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "fastly";
|
|
|
|
repo = "cli";
|
|
|
|
rev = "v${version}";
|
2022-12-04 02:38:28 +00:00
|
|
|
sha256 = "sha256-82OZwO6r+wPq6AMm27M9U6dQyE3iOpAzW31HzRji5Fo=";
|
2022-04-24 09:50:16 +00:00
|
|
|
# The git commit is part of the `fastly version` original output;
|
|
|
|
# leave that output the same in nixpkgs. Use the `.git` directory
|
|
|
|
# to retrieve the commit SHA, and remove the directory afterwards,
|
|
|
|
# since it is not needed after that.
|
|
|
|
leaveDotGit = true;
|
|
|
|
postFetch = ''
|
|
|
|
cd "$out"
|
|
|
|
git rev-parse --short HEAD > $out/COMMIT
|
|
|
|
find "$out" -name .git -print0 | xargs -0 rm -rf
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
subPackages = [ "cmd/fastly" ];
|
|
|
|
|
2022-12-01 22:02:34 +00:00
|
|
|
vendorSha256 = "sha256-zilgzfPD7HmHt0/u94JLaY6NPvn1JjXFu1K2YO0tF9M=";
|
2022-04-24 09:50:16 +00:00
|
|
|
|
|
|
|
nativeBuildInputs = [ installShellFiles ];
|
|
|
|
|
|
|
|
# Flags as provided by the build automation of the project:
|
|
|
|
# https://github.com/fastly/cli/blob/7844f9f54d56f8326962112b5534e5c40e91bf09/.goreleaser.yml#L14-L18
|
|
|
|
ldflags = [
|
|
|
|
"-s"
|
|
|
|
"-w"
|
|
|
|
"-X github.com/fastly/cli/pkg/revision.AppVersion=v${version}"
|
|
|
|
"-X github.com/fastly/cli/pkg/revision.Environment=release"
|
2022-07-26 14:29:06 +00:00
|
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostOS=${go.GOHOSTOS}"
|
|
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostArch=${go.GOHOSTARCH}"
|
2022-04-24 09:50:16 +00:00
|
|
|
];
|
2022-10-21 15:01:26 +00:00
|
|
|
preBuild = let
|
|
|
|
cliConfigToml = fetchurl {
|
|
|
|
url = "https://web.archive.org/web/20221104122906/https://developer.fastly.com/api/internal/cli-config";
|
|
|
|
sha256 = "sha256-BHsUWrMp//X95gcB+WbD/nfyduZUkH8jHXk3CfOBAhg=";
|
|
|
|
};
|
|
|
|
in ''
|
|
|
|
cp ${cliConfigToml} ./pkg/config/config.toml
|
2022-04-24 09:50:16 +00:00
|
|
|
ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)"
|
|
|
|
'';
|
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
export HOME="$(mktemp -d)"
|
|
|
|
installShellCompletion --cmd fastly \
|
|
|
|
--bash <($out/bin/fastly --completion-script-bash) \
|
|
|
|
--zsh <($out/bin/fastly --completion-script-zsh)
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "Command line tool for interacting with the Fastly API";
|
|
|
|
license = licenses.asl20;
|
|
|
|
homepage = "https://github.com/fastly/cli";
|
|
|
|
maintainers = with maintainers; [ ereslibre shyim ];
|
|
|
|
};
|
|
|
|
}
|