2020-04-24 23:36:52 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchurl
|
2021-06-28 23:13:55 +00:00
|
|
|
, buildPythonApplication
|
2020-04-24 23:36:52 +00:00
|
|
|
, colorclass
|
2021-06-28 23:13:55 +00:00
|
|
|
, installShellFiles
|
2020-04-24 23:36:52 +00:00
|
|
|
, pyyaml
|
2021-06-28 23:13:55 +00:00
|
|
|
, requests
|
2020-04-24 23:36:52 +00:00
|
|
|
, setuptools
|
2021-06-28 23:13:55 +00:00
|
|
|
, terminaltables
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-12-06 16:07:01 +00:00
|
|
|
sha256 = "1kvlf9qcl0i7g24s9f2pj25msmlj0cjicjwrnnc65q8qkmk2br9q";
|
2021-07-17 21:14:59 +00:00
|
|
|
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
|
2021-12-06 16:07:01 +00:00
|
|
|
specVersion = "4.108.0";
|
|
|
|
specSha256 = "17n9wjd0hpkzc2bvsawdvl8hc5285r0n19xq59h4amqb2fhp676w";
|
2020-04-24 23:36:52 +00:00
|
|
|
spec = fetchurl {
|
2021-06-28 23:13:55 +00:00
|
|
|
url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml";
|
2021-09-23 15:35:13 +00:00
|
|
|
sha256 = specSha256;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
buildPythonApplication rec {
|
|
|
|
pname = "linode-cli";
|
2021-12-06 16:07:01 +00:00
|
|
|
version = "5.12.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "linode";
|
|
|
|
repo = pname;
|
|
|
|
rev = version;
|
2021-09-23 15:35:13 +00:00
|
|
|
inherit sha256;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
# remove need for git history
|
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace setup.py \
|
|
|
|
--replace "version=get_version()," "version='${version}',"
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
colorclass
|
|
|
|
pyyaml
|
2021-06-28 23:13:55 +00:00
|
|
|
requests
|
2020-04-24 23:36:52 +00:00
|
|
|
setuptools
|
2021-06-28 23:13:55 +00:00
|
|
|
terminaltables
|
2020-04-24 23:36:52 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
postConfigure = ''
|
|
|
|
python3 -m linodecli bake ${spec} --skip-config
|
|
|
|
cp data-3 linodecli/
|
|
|
|
'';
|
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
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)
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-09-23 15:35:13 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
meta = with lib; {
|
|
|
|
description = "The Linode Command Line Interface";
|
2021-06-28 23:13:55 +00:00
|
|
|
homepage = "https://github.com/linode/linode-cli";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd3;
|
2021-12-06 16:07:01 +00:00
|
|
|
maintainers = with maintainers; [ ryantm ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|