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
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "1fv53wikx745kci86xrsq9kfsgv0a65srhywdw32cab1wywwpn2z";
|
2021-07-17 21:14:59 +00:00
|
|
|
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
|
2022-09-09 14:08:57 +00:00
|
|
|
specVersion = "4.133.0";
|
|
|
|
specSha256 = "1jcjfnagjihcy03fcmn5sghdf7a80798xjgj1x7z3ncqwd5aggwg";
|
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";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "5.22.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
|
|
|
};
|
|
|
|
|
2022-04-03 18:54:34 +00:00
|
|
|
patches = [
|
|
|
|
./remove-update-check.patch
|
|
|
|
];
|
|
|
|
|
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
|
|
|
};
|
|
|
|
}
|