depot/third_party/nixpkgs/pkgs/tools/virtualization/linode-cli/default.nix
Default email bb584b27e9 Project import generated by Copybara.
GitOrigin-RevId: 5181d5945eda382ff6a9ca3e072ed6ea9b547fee
2022-04-15 03:41:22 +02:00

77 lines
1.7 KiB
Nix

{ lib
, fetchFromGitHub
, fetchurl
, buildPythonApplication
, colorclass
, installShellFiles
, pyyaml
, requests
, setuptools
, terminaltables
}:
let
sha256 = "1f0nrdg8hf650qxz79i3a1d2zyf24niyrcnbnhc9i7hzbnqbp5qg";
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
specVersion = "4.119.4";
specSha256 = "057qzpy8da0r0av8wmm640mqqhl4qynqxqalkf3ylsa3xnch5c9m";
spec = fetchurl {
url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml";
sha256 = specSha256;
};
in
buildPythonApplication rec {
pname = "linode-cli";
version = "5.17.2";
src = fetchFromGitHub {
owner = "linode";
repo = pname;
rev = version;
inherit sha256;
};
patches = [
./remove-update-check.patch
];
# remove need for git history
prePatch = ''
substituteInPlace setup.py \
--replace "version=get_version()," "version='${version}',"
'';
propagatedBuildInputs = [
colorclass
pyyaml
requests
setuptools
terminaltables
];
postConfigure = ''
python3 -m linodecli bake ${spec} --skip-config
cp data-3 linodecli/
'';
doInstallCheck = true;
installCheckPhase = ''
$out/bin/linode-cli --skip-config --version | grep ${version} > /dev/null
'';
nativeBuildInputs = [ installShellFiles ];
postInstall = ''
installShellCompletion --cmd linode-cli --bash <($out/bin/linode-cli --skip-config completion bash)
'';
passthru.updateScript = ./update.sh;
meta = with lib; {
description = "The Linode Command Line Interface";
homepage = "https://github.com/linode/linode-cli";
license = licenses.bsd3;
maintainers = with maintainers; [ ryantm ];
};
}