2022-12-04 13:50:06 +01:00
|
|
|
{ lib
|
|
|
|
, fetchurl
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, buildGoModule
|
|
|
|
, go
|
2023-03-07 22:39:05 +01:00
|
|
|
, makeWrapper
|
|
|
|
, viceroy
|
2022-12-04 13:50:06 +01:00
|
|
|
}:
|
2022-04-24 11:50:16 +02:00
|
|
|
|
|
|
|
buildGoModule rec {
|
|
|
|
pname = "fastly";
|
2024-03-02 05:40:51 +01:00
|
|
|
version = "10.8.4";
|
2022-04-24 11:50:16 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "fastly";
|
|
|
|
repo = "cli";
|
2022-12-04 13:50:06 +01:00
|
|
|
rev = "refs/tags/v${version}";
|
2024-03-02 05:40:51 +01:00
|
|
|
hash = "sha256-l81DZUWP7/rCEkE/ZPuwcnVGOcbSFKe88lfduJdygu4=";
|
2022-04-24 11:50:16 +02: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
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-12-04 13:50:06 +01:00
|
|
|
subPackages = [
|
|
|
|
"cmd/fastly"
|
|
|
|
];
|
2022-04-24 11:50:16 +02:00
|
|
|
|
2024-02-21 21:02:29 +01:00
|
|
|
vendorHash = "sha256-lTpj9fZ4SJzOdLwIVZxiZCUJxHC41BvwvDOctwckO5k=";
|
2022-04-24 11:50:16 +02:00
|
|
|
|
2022-12-04 13:50:06 +01:00
|
|
|
nativeBuildInputs = [
|
|
|
|
installShellFiles
|
2023-03-07 22:39:05 +01:00
|
|
|
makeWrapper
|
2022-12-04 13:50:06 +01:00
|
|
|
];
|
2022-04-24 11:50:16 +02:00
|
|
|
|
|
|
|
# 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 16:29:06 +02:00
|
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostOS=${go.GOHOSTOS}"
|
|
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostArch=${go.GOHOSTARCH}"
|
2022-04-24 11:50:16 +02:00
|
|
|
];
|
2022-10-21 17:01:26 +02:00
|
|
|
preBuild = let
|
|
|
|
cliConfigToml = fetchurl {
|
2023-11-30 16:42:11 +01:00
|
|
|
url = "https://web.archive.org/web/20231130153524/https://developer.fastly.com/api/internal/cli-config";
|
|
|
|
hash = "sha256-ZKr6D4DI+lr8FDjfLMgpn4Zq4i5kiwcLEDEScuuCBBw=";
|
2022-10-21 17:01:26 +02:00
|
|
|
};
|
|
|
|
in ''
|
|
|
|
cp ${cliConfigToml} ./pkg/config/config.toml
|
2022-04-24 11:50:16 +02:00
|
|
|
ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)"
|
|
|
|
'';
|
|
|
|
|
2023-03-07 22:39:05 +01:00
|
|
|
preFixup = ''
|
|
|
|
wrapProgram $out/bin/fastly --prefix PATH : ${lib.makeBinPath [ viceroy ]} \
|
|
|
|
--set FASTLY_VICEROY_USE_PATH 1
|
|
|
|
'';
|
|
|
|
|
2022-04-24 11:50:16 +02:00
|
|
|
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";
|
|
|
|
homepage = "https://github.com/fastly/cli";
|
2022-12-04 13:50:06 +01:00
|
|
|
changelog = "https://github.com/fastly/cli/blob/v${version}/CHANGELOG.md";
|
|
|
|
license = licenses.asl20;
|
2022-04-24 11:50:16 +02:00
|
|
|
maintainers = with maintainers; [ ereslibre shyim ];
|
2023-11-23 22:09:35 +01:00
|
|
|
mainProgram = "fastly";
|
2022-04-24 11:50:16 +02:00
|
|
|
};
|
|
|
|
}
|