From 6a0ff02d5e2f7b935336d82136525163f915c8b0 Mon Sep 17 00:00:00 2001 From: Dionysis Grigoropoulos Date: Tue, 26 Nov 2024 20:55:06 +0200 Subject: [PATCH] python3Packages.llm-cmd: init at 0.2a0 --- .../python-modules/llm-cmd/default.nix | 55 +++++++++++++++++++ .../python-modules/llm-cmd/fix-test.patch | 13 +++++ pkgs/top-level/python-packages.nix | 2 + 3 files changed, 70 insertions(+) create mode 100644 pkgs/development/python-modules/llm-cmd/default.nix create mode 100644 pkgs/development/python-modules/llm-cmd/fix-test.patch diff --git a/pkgs/development/python-modules/llm-cmd/default.nix b/pkgs/development/python-modules/llm-cmd/default.nix new file mode 100644 index 000000000000..e4f9335dd1d2 --- /dev/null +++ b/pkgs/development/python-modules/llm-cmd/default.nix @@ -0,0 +1,55 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + # build-system + setuptools, + llm, + # dependencies + prompt-toolkit, + pygments, + # tests + pytestCheckHook, +}: + +buildPythonPackage rec { + pname = "llm-cmd"; + version = "0.2a0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "simonw"; + repo = "llm-cmd"; + tag = version; + hash = "sha256-RhwQEllpee/XP1p0nrgL4m+KjSZzf61J8l1jJGlg94E="; + }; + + # Only needed until https://github.com/simonw/llm-cmd/pull/18 is merged and released + patches = [ ./fix-test.patch ]; + build-system = [ + setuptools + # Follows the reasoning from https://github.com/NixOS/nixpkgs/pull/327800#discussion_r1681586659 about including llm in build-system + llm + ]; + + dependencies = [ + prompt-toolkit + pygments + ]; + + nativeCheckInputs = [ + pytestCheckHook + ]; + + pythonImportCheck = [ + "llm_cmd" + ]; + + meta = { + description = "Use LLM to generate and execute commands in your shell"; + homepage = "https://github.com/simonw/llm-cmd"; + changelog = "https://github.com/simonw/llm-cmd/releases/tag/${version}"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ erethon ]; + }; +} diff --git a/pkgs/development/python-modules/llm-cmd/fix-test.patch b/pkgs/development/python-modules/llm-cmd/fix-test.patch new file mode 100644 index 000000000000..421a9f9cf098 --- /dev/null +++ b/pkgs/development/python-modules/llm-cmd/fix-test.patch @@ -0,0 +1,13 @@ +diff --git a/tests/test_cmd.py b/tests/test_cmd.py +index 02b5db8..578ebaa 100644 +--- a/tests/test_cmd.py ++++ b/tests/test_cmd.py +@@ -1,6 +1,7 @@ +-from llm.plugins import pm ++from llm.plugins import load_plugins, pm + + + def test_plugin_is_installed(): ++ load_plugins() + names = [mod.__name__ for mod in pm.get_plugins()] + assert "llm_cmd" in names diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 219366808473..67fd153b1eeb 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -7619,6 +7619,8 @@ self: super: with self; { llm = callPackage ../development/python-modules/llm { }; + llm-cmd = callPackage ../development/python-modules/llm-cmd { }; + llm-gguf = callPackage ../development/python-modules/llm-gguf { }; llmx = callPackage ../development/python-modules/llmx { };