1{ 2 stdenv, 3 buildPythonApplication, 4 colorclass, 5 fetchPypi, 6 fetchurl, 7 installShellFiles, 8 lib, 9 linode-metadata, 10 openapi3, 11 packaging, 12 pyyaml, 13 requests, 14 rich, 15 setuptools, 16 terminaltables, 17}: 18 19let 20 hash = "sha256-QQxadKVEIh1PvD8FdYgJ/U1iyWdy6FvO+LUELQ70KKw="; 21 # specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`. 22 specVersion = "4.176.0"; 23 specHash = "sha256-P1E8Ga5ckrsw/CX0kxFef5fe8/p/pDCLuleX9wR5l48="; 24 spec = fetchurl { 25 url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml"; 26 hash = specHash; 27 }; 28 29in 30 31buildPythonApplication rec { 32 pname = "linode-cli"; 33 version = "5.56.2"; 34 pyproject = true; 35 36 src = fetchPypi { 37 pname = "linode_cli"; 38 inherit version; 39 hash = hash; 40 }; 41 42 patches = [ ./remove-update-check.patch ]; 43 44 # remove need for git history 45 prePatch = '' 46 substituteInPlace setup.py \ 47 --replace "version = get_version()" "version='${version}'," 48 ''; 49 50 postConfigure = '' 51 python3 -m linodecli bake ${spec} --skip-config 52 cp data-3 linodecli/ 53 echo "${version}" > baked_version 54 ''; 55 56 nativeBuildInputs = [ installShellFiles ]; 57 58 propagatedBuildInputs = [ 59 colorclass 60 linode-metadata 61 pyyaml 62 requests 63 setuptools 64 terminaltables 65 rich 66 openapi3 67 packaging 68 ]; 69 70 doInstallCheck = true; 71 installCheckPhase = '' 72 $out/bin/linode-cli --skip-config --version | grep ${version} > /dev/null 73 ''; 74 75 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' 76 for shell in bash fish; do 77 installShellCompletion --cmd linode-cli \ 78 --$shell <($out/bin/linode-cli --skip-config completion $shell) 79 done 80 ''; 81 82 passthru.updateScript = ./update.sh; 83 84 meta = { 85 description = "Linode Command Line Interface"; 86 changelog = "https://github.com/linode/linode-cli/releases/tag/v${version}"; 87 downloadPage = "https://pypi.org/project/linode-cli"; 88 homepage = "https://github.com/linode/linode-cli"; 89 license = lib.licenses.bsd3; 90 maintainers = with lib.maintainers; [ 91 ryantm 92 techknowlogick 93 ]; 94 mainProgram = "linode-cli"; 95 }; 96}