1{ lib
2, buildPythonApplication
3, fetchFromGitHub
4, fetchurl
5, terminaltables
6, colorclass
7, requests
8, pyyaml
9, setuptools
10, installShellFiles
11}:
12
13let
14
15 spec = fetchurl {
16 url = "https://raw.githubusercontent.com/linode/linode-api-docs/v4.89.0/openapi.yaml";
17 sha256 = "sha256-R7Dmq8ifGEjh47ftuoGrbymYBsPCj/ULz0j1OqJDcwY=";
18 };
19
20in
21
22buildPythonApplication rec {
23 pname = "linode-cli";
24 version = "5.0.1";
25
26 src = fetchFromGitHub {
27 owner = "linode";
28 repo = pname;
29 rev = version;
30 sha256 = "sha256-zelopRaHaDCnbYA/y7dNMBh70g0+wuc6t9LH/VLaUIk=";
31 };
32
33 # remove need for git history
34 prePatch = ''
35 substituteInPlace setup.py \
36 --replace "version=get_version()," "version='${version}',"
37 '';
38
39 propagatedBuildInputs = [
40 terminaltables
41 colorclass
42 requests
43 pyyaml
44 setuptools
45 ];
46
47 postConfigure = ''
48 python3 -m linodecli bake ${spec} --skip-config
49 cp data-3 linodecli/
50 '';
51
52 doInstallCheck = true;
53 installCheckPhase = ''
54 $out/bin/linode-cli --skip-config --version | grep ${version} > /dev/null
55 '';
56
57 nativeBuildInputs = [ installShellFiles ];
58 postInstall = ''
59 installShellCompletion --cmd linode-cli --bash <($out/bin/linode-cli --skip-config completion bash)
60 '';
61
62 meta = with lib; {
63 homepage = "https://github.com/linode/linode-cli";
64 description = "The Linode Command Line Interface";
65 license = licenses.bsd3;
66 maintainers = with maintainers; [ ryantm superherointj ];
67 };
68
69}