Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
90 lines
2.5 KiB
Nix
90 lines
2.5 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchurl,
|
|
fetchFromGitHub,
|
|
installShellFiles,
|
|
buildGoModule,
|
|
go,
|
|
makeWrapper,
|
|
viceroy,
|
|
}:
|
|
|
|
buildGoModule rec {
|
|
pname = "fastly";
|
|
version = "12.1.0";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "fastly";
|
|
repo = "cli";
|
|
tag = "v${version}";
|
|
hash = "sha256-P5n1CWGVu5rdfLOlKgnx5JtwDoI35y3zlvcqp48vQ7g=";
|
|
# 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"
|
|
];
|
|
|
|
vendorHash = "sha256-ff65Vi0BmYF72MbrMmFzqDTXQWaEtaBQaPdLub8ZToo=";
|
|
|
|
nativeBuildInputs = [
|
|
installShellFiles
|
|
makeWrapper
|
|
];
|
|
|
|
# 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"
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostOS=${go.GOHOSTOS}"
|
|
"-X github.com/fastly/cli/pkg/revision.GoHostArch=${go.GOHOSTARCH}"
|
|
];
|
|
preBuild =
|
|
let
|
|
cliConfigToml = fetchurl {
|
|
url = "https://web.archive.org/web/20240910172801/https://developer.fastly.com/api/internal/cli-config";
|
|
hash = "sha256-r4ahroyU4hyTN88UK02FvXU8OTQ6OoNInt9WrzZk7Bk=";
|
|
};
|
|
in
|
|
''
|
|
cp ${cliConfigToml} ./pkg/config/config.toml
|
|
ldflags+=" -X github.com/fastly/cli/pkg/revision.GitCommit=$(cat COMMIT)"
|
|
'';
|
|
|
|
preFixup = ''
|
|
wrapProgram $out/bin/fastly --prefix PATH : ${lib.makeBinPath [ viceroy ]} \
|
|
--set FASTLY_VICEROY_USE_PATH 1
|
|
'';
|
|
|
|
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
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";
|
|
changelog = "https://github.com/fastly/cli/blob/v${version}/CHANGELOG.md";
|
|
license = licenses.asl20;
|
|
maintainers = with maintainers; [
|
|
ereslibre
|
|
];
|
|
mainProgram = "fastly";
|
|
};
|
|
}
|