nixpkgs/pkgs/tools/virtualization/linode-cli/default.nix

70 lines
1.6 KiB
Nix
Raw Normal View History

{ lib
, fetchFromGitHub
, fetchurl
2021-06-23 23:56:50 +00:00
, buildPythonApplication
, colorclass
2021-06-23 23:56:50 +00:00
, installShellFiles
, pyyaml
2021-06-23 23:56:50 +00:00
, requests
, setuptools
2021-06-23 23:56:50 +00:00
, terminaltables
}:
2017-05-01 16:58:54 +00:00
let
2021-07-17 12:16:07 +00:00
# specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`.
2021-08-26 01:12:21 +00:00
specVersion = "4.102.0";
spec = fetchurl {
2021-06-23 23:56:50 +00:00
url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml";
2021-08-26 01:12:21 +00:00
sha256 = "16njk21gdk8r8a9v607ndw2rs0q6za9ylkgdxmix4j0zvrbrw0qv";
};
in
buildPythonApplication rec {
pname = "linode-cli";
2021-08-26 01:12:21 +00:00
version = "5.8.1";
2017-05-01 16:58:54 +00:00
src = fetchFromGitHub {
owner = "linode";
repo = pname;
rev = version;
2021-08-26 01:12:21 +00:00
sha256 = "19lfnwgm09gxk0mcikwl7v4hw2ai2k9lkdjlalz8fsswf81my7h6";
2017-05-01 16:58:54 +00:00
};
# remove need for git history
prePatch = ''
substituteInPlace setup.py \
--replace "version=get_version()," "version='${version}',"
2017-05-01 16:58:54 +00:00
'';
propagatedBuildInputs = [
colorclass
pyyaml
2021-06-23 23:56:50 +00:00
requests
setuptools
2021-06-23 23:56:50 +00:00
terminaltables
];
2017-05-01 16:58:54 +00:00
postConfigure = ''
python3 -m linodecli bake ${spec} --skip-config
cp data-3 linodecli/
'';
2017-05-01 16:58:54 +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)
'';
meta = with lib; {
description = "The Linode Command Line Interface";
2021-06-23 23:56:50 +00:00
homepage = "https://github.com/linode/linode-cli";
license = licenses.bsd3;
maintainers = with maintainers; [ ryantm superherointj ];
2017-05-01 16:58:54 +00:00
};
}