Skip to content

Commit

Permalink
python3Packages.llm-cmd: init at 0.2a0 (NixOS#359379)
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage authored Jan 8, 2025
2 parents 0b5b716 + 6a0ff02 commit f9aff72
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
55 changes: 55 additions & 0 deletions pkgs/development/python-modules/llm-cmd/default.nix
Original file line number Diff line number Diff line change
@@ -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 ];
};
}
13 changes: 13 additions & 0 deletions pkgs/development/python-modules/llm-cmd/fix-test.patch
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions pkgs/top-level/python-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7623,6 +7623,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 { };

llm-ollama = callPackage ../development/python-modules/llm-ollama { };
Expand Down

0 comments on commit f9aff72

Please sign in to comment.