diff --git a/pkgs/development/python-modules/linode-metadata/default.nix b/pkgs/development/python-modules/linode-metadata/default.nix new file mode 100644 index 000000000000..a7b47d18efdc --- /dev/null +++ b/pkgs/development/python-modules/linode-metadata/default.nix @@ -0,0 +1,44 @@ +{ + buildPythonPackage, + fetchPypi, + httpx, + lib, + linode-cli, + pytest, + pytest-asyncio, + setuptools, +}: + +buildPythonPackage rec { + pname = "linode-metadata"; + version = "0.3.0"; + + src = fetchPypi { + pname = "linode_metadata"; + inherit version; + hash = "sha256-ZFCv9f4hbiBaJuKvzs/BGFoP+mAFwVa8OFF22b22voI="; + }; + + pyproject = true; + + dependencies = [ + httpx + setuptools + ]; + + checkInputs = [ + pytest + pytest-asyncio + ]; + + pythonImportsCheck = [ "linode_metadata" ]; + + meta = { + description = "Python package for interacting with the Linode Metadata Service"; + downloadPage = "https://pypi.org/project/linode-metadata/"; + homepage = "https://github.com/linode/py-metadata"; + changelog = "https://github.com/linode/py-metadata/releases/tag/v${version}"; + license = lib.licenses.bsd3; + maintainers = linode-cli.meta.maintainers; + }; +} diff --git a/pkgs/tools/virtualization/linode-cli/default.nix b/pkgs/tools/virtualization/linode-cli/default.nix index 795eb1e8636e..5d28513787e8 100644 --- a/pkgs/tools/virtualization/linode-cli/default.nix +++ b/pkgs/tools/virtualization/linode-cli/default.nix @@ -1,23 +1,25 @@ -{ lib -, fetchFromGitHub -, fetchurl -, buildPythonApplication -, colorclass -, installShellFiles -, pyyaml -, requests -, setuptools -, terminaltables -, rich -, openapi3 -, packaging +{ + buildPythonApplication, + colorclass, + fetchPypi, + fetchurl, + installShellFiles, + lib, + linode-metadata, + openapi3, + packaging, + pyyaml, + requests, + rich, + setuptools, + terminaltables, }: let - hash = "sha256-J0L+FTVzYuAqTDOwpoH12lQr03UNo5dsQpd/iUKR40Q="; + hash = "sha256-IXltDBgabTBDw0y7IXgRGpAWVUyqeJI8EfxkZ5YuQrU="; # specVersion taken from: https://www.linode.com/docs/api/openapi.yaml at `info.version`. - specVersion = "4.166.0"; - specHash = "sha256-rUwKQt3y/ALZUoW3eJiiIDJYLQpUHO7Abm0h09ra02g="; + specVersion = "4.176.0"; + specHash = "sha256-P1E8Ga5ckrsw/CX0kxFef5fe8/p/pDCLuleX9wR5l48="; spec = fetchurl { url = "https://raw.githubusercontent.com/linode/linode-api-docs/v${specVersion}/openapi.yaml"; hash = specHash; @@ -27,19 +29,16 @@ in buildPythonApplication rec { pname = "linode-cli"; - version = "5.45.0"; + version = "5.50.0"; pyproject = true; - src = fetchFromGitHub { - owner = "linode"; - repo = pname; - rev = "v${version}"; - inherit hash; + src = fetchPypi { + pname = "linode_cli"; + inherit version; + hash = "sha256-OCnO7Bf2tDnC4g7kYS0WFlV9plAS25GbzRO6mpDYYxk="; }; - patches = [ - ./remove-update-check.patch - ]; + patches = [ ./remove-update-check.patch ]; # remove need for git history prePatch = '' @@ -47,8 +46,17 @@ buildPythonApplication rec { --replace "version = get_version()" "version='${version}'," ''; + postConfigure = '' + python3 -m linodecli bake ${spec} --skip-config + cp data-3 linodecli/ + echo "${version}" > baked_version + ''; + + nativeBuildInputs = [ installShellFiles ]; + propagatedBuildInputs = [ colorclass + linode-metadata pyyaml requests setuptools @@ -58,29 +66,30 @@ buildPythonApplication rec { packaging ]; - postConfigure = '' - python3 -m linodecli bake ${spec} --skip-config - cp data-3 linodecli/ - echo "${version}" > baked_version - ''; - 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) + for shell in bash fish; do + installShellCompletion --cmd linode-cli \ + --$shell <($out/bin/linode-cli --skip-config completion $shell) + done ''; passthru.updateScript = ./update.sh; - meta = with lib; { - mainProgram = "linode-cli"; + meta = { description = "Linode Command Line Interface"; + changelog = "https://github.com/linode/linode-cli/releases/tag/v${version}"; + downloadPage = "https://pypi.org/project/linode-cli"; homepage = "https://github.com/linode/linode-cli"; - license = licenses.bsd3; - maintainers = with maintainers; [ ryantm techknowlogick ]; + license = lib.licenses.bsd3; + maintainers = with lib.maintainers; [ + ryantm + techknowlogick + ]; + mainProgram = "linode-cli"; }; } diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e6b0da130ca3..9cd250fb2997 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -6996,6 +6996,8 @@ self: super: with self; { linode-api = callPackage ../development/python-modules/linode-api { }; + linode-metadata = callPackage ../development/python-modules/linode-metadata { }; + linode = callPackage ../development/python-modules/linode { }; linuxfd = callPackage ../development/python-modules/linuxfd { };