Files
nixpkgs/pkgs/by-name/sc/scaleway-cli/package.nix
2026-08-18 12:45:35 +00:00

81 lines
2.2 KiB
Nix

{
stdenv,
lib,
fetchFromGitHub,
buildGo126Module,
installShellFiles,
versionCheckHook,
writableTmpDirAsHomeHook,
}:
buildGo126Module (finalAttrs: {
pname = "scaleway-cli";
version = "2.61.0";
src = fetchFromGitHub {
owner = "scaleway";
repo = "scaleway-cli";
tag = "v${finalAttrs.version}";
hash = "sha256-e65O97Rnmt80VriwU6XRp0JiNftaN+4X+o1jXh3skTA=";
};
vendorHash = "sha256-LeIwKTuTNdrFg8zF006JrGW3hzlXHr9o5k6GHKdUNIQ=";
env.CGO_ENABLED = 0;
ldflags = [
"-s"
"-w"
"-X main.Version=${finalAttrs.src.tag}"
"-X main.GitCommit=${finalAttrs.src.rev}"
"-X main.GitBranch=HEAD"
"-X main.BuildDate=1970-01-01T00:00:00Z"
];
subPackages = [
"cmd/scw"
"commands/..."
"core/..."
"internal/..."
];
nativeBuildInputs = [ installShellFiles ];
nativeInstallCheckInputs = [ versionCheckHook ];
nativeCheckInputs = [ writableTmpDirAsHomeHook ];
checkFlags = [
# This subtest hardcodes a go-humanize relative-time string ("35 years ago")
# for a fixed 1990 date instead of computing it, so it breaks once enough
# wall-clock time passes (now "36 years ago"). go-humanize truncates the
# elapsed time by a fixed 360-day year (Year = 12*Month, Month = 30*Day), so
# diff/Year rolled 35 -> 36 on 2026-05-12. Upstream keeps bumping the
# literal by hand rather than fixing it, so skip the time-dependent subtest.
"-skip=^TestMarshal/structWithMapsInSection$"
];
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
$out/bin/scw autocomplete script basename=scw shell=bash >scw.bash
$out/bin/scw autocomplete script basename=scw shell=fish >scw.fish
echo '#compdef scw' >scw.zsh
$out/bin/scw autocomplete script basename=scw shell=zsh >>scw.zsh
installShellCompletion scw.{bash,fish,zsh}
'';
doInstallCheck = true;
versionCheckProgramArg = "version";
__darwinAllowLocalNetworking = true;
meta = {
description = "Command Line Interface for Scaleway";
homepage = "https://github.com/scaleway/scaleway-cli";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
nickhu
techknowlogick
kashw2
];
mainProgram = "scw";
};
})