2020-04-14 23:49:00 +00:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, fetchurl
|
2021-06-23 23:56:50 +00:00
|
|
|
, buildPythonApplication
|
2020-04-14 23:49:00 +00:00
|
|
|
, colorclass
|
2021-06-23 23:56:50 +00:00
|
|
|
, installShellFiles
|
2020-04-14 23:49:00 +00:00
|
|
|
, pyyaml
|
2021-06-23 23:56:50 +00:00
|
|
|
, requests
|
2020-04-14 23:49:00 +00:00
|
|
|
, setuptools
|
2021-06-23 23:56:50 +00:00
|
|
|
, terminaltables
|
2023-11-04 03:14:41 +00:00
|
|
|
, rich
|
|
|
|
, openapi3
|
|
|
|
, packaging
|
2020-04-14 23:49:00 +00:00
|
|
|
}:
|
2017-05-01 16:58:54 +00:00
|
|
|
|
2020-04-14 23:49:00 +00:00
|
|
|
let
|
2023-11-04 03:14:41 +00:00
|
|
|
hash = "sha256-J0L+FTVzYuAqTDOwpoH12lQr03UNo5dsQpd/iUKR40Q=";
|
2021-07-17 12:16:07 +00:00
|
|
|
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
|
2023-11-04 03:14:41 +00:00
|
|
|
specVersion = "4.166.0";
|
|
|
|
specHash = "sha256-rUwKQt3y/ALZUoW3eJiiIDJYLQpUHO7Abm0h09ra02g=";
|
2020-04-14 23:49:00 +00:00
|
|
|
spec = fetchurl {
|
2021-06-23 23:56:50 +00:00
|
|
|
url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml";
|
2023-11-04 03:14:41 +00:00
|
|
|
hash = specHash;
|
2020-04-14 23:49:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
buildPythonApplication rec {
|
2019-06-20 13:07:56 +00:00
|
|
|
pname = "linode-cli";
|
2023-11-04 03:14:41 +00:00
|
|
|
version = "5.45.0";
|
|
|
|
pyproject = true;
|
2017-05-01 16:58:54 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "linode";
|
2020-04-14 23:49:00 +00:00
|
|
|
repo = pname;
|
2023-11-04 03:14:41 +00:00
|
|
|
rev = "v${version}";
|
|
|
|
inherit hash;
|
2017-05-01 16:58:54 +00:00
|
|
|
};
|
|
|
|
|
2022-04-01 19:38:49 +00:00
|
|
|
patches = [
|
|
|
|
./remove-update-check.patch
|
|
|
|
];
|
|
|
|
|
2020-04-14 23:49:00 +00:00
|
|
|
# remove need for git history
|
|
|
|
prePatch = ''
|
|
|
|
substituteInPlace setup.py \
|
2023-11-04 03:14:41 +00:00
|
|
|
--replace "version = get_version()" "version='${version}',"
|
2017-05-01 16:58:54 +00:00
|
|
|
'';
|
|
|
|
|
2020-04-14 23:49:00 +00:00
|
|
|
propagatedBuildInputs = [
|
|
|
|
colorclass
|
|
|
|
pyyaml
|
2021-06-23 23:56:50 +00:00
|
|
|
requests
|
2020-04-14 23:49:00 +00:00
|
|
|
setuptools
|
2021-06-23 23:56:50 +00:00
|
|
|
terminaltables
|
2023-11-04 03:14:41 +00:00
|
|
|
rich
|
|
|
|
openapi3
|
|
|
|
packaging
|
2020-04-14 23:49:00 +00:00
|
|
|
];
|
2017-05-01 16:58:54 +00:00
|
|
|
|
2020-04-14 23:49:00 +00:00
|
|
|
postConfigure = ''
|
|
|
|
python3 -m linodecli bake ${spec} --skip-config
|
|
|
|
cp data-3 linodecli/
|
2023-11-04 03:14:41 +00:00
|
|
|
echo "${version}" > baked_version
|
2020-04-14 23:49:00 +00:00
|
|
|
'';
|
2017-05-01 16:58:54 +00:00
|
|
|
|
2021-04-20 21:21:29 +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-14 23:49:00 +00:00
|
|
|
|
2021-09-22 19:41:14 +00:00
|
|
|
passthru.updateScript = ./update.sh;
|
|
|
|
|
2020-04-14 23:49:00 +00:00
|
|
|
meta = with lib; {
|
2023-11-04 03:14:41 +00:00
|
|
|
mainProgram = "linode-cli";
|
2020-04-14 23:49:00 +00:00
|
|
|
description = "The Linode Command Line Interface";
|
2021-06-23 23:56:50 +00:00
|
|
|
homepage = "https://github.com/linode/linode-cli";
|
2020-04-14 23:49:00 +00:00
|
|
|
license = licenses.bsd3;
|
2023-10-24 05:24:24 +00:00
|
|
|
maintainers = with maintainers; [ ryantm techknowlogick ];
|
2017-05-01 16:58:54 +00:00
|
|
|
};
|
|
|
|
}
|