diff --git a/home/progs/pi.nix b/home/progs/pi.nix index ffcd922..e9fa45b 100644 --- a/home/progs/pi.nix +++ b/home/progs/pi.nix @@ -119,6 +119,50 @@ let }; }; + # OMP's `eval` tool drives a Jupyter kernel for Python execution. It refuses + # ("Python backend is unavailable") unless both `kernel_gateway` + # (jupyter-kernel-gateway) and `ipykernel` are importable from the python it + # selects. nixpkgs ships ipykernel but not jupyter-kernel-gateway, so we + # build it here from the PyPI sdist. + jupyter-kernel-gateway = pkgs.python3Packages.buildPythonPackage rec { + pname = "jupyter_kernel_gateway"; + version = "3.0.1"; + pyproject = true; + src = pkgs.python3Packages.fetchPypi { + inherit pname version; + hash = "sha256-kAaQxMDnloZzVUaNaF9/oc88d3XQjoccFX931l+9bX8="; + }; + nativeBuildInputs = [ pkgs.python3Packages.hatchling ]; + propagatedBuildInputs = with pkgs.python3Packages; [ + jupyter-client + jupyter-core + jupyter-server + requests + tornado + traitlets + ]; + # Upstream test suite hits the network and pulls pytest-jupyter; the import + # check is enough to confirm the package wires up correctly. + doCheck = false; + pythonImportsCheck = [ "kernel_gateway" ]; + meta = { + description = "Jupyter Kernel Gateway: headless web server for Jupyter kernels"; + homepage = "https://github.com/jupyter/kernel_gateway"; + license = lib.licenses.bsd3; + }; + }; + + # Python env exposed to omp as its "managed venv" at ~/.omp/python-env. omp's + # runtime resolver (packages/coding-agent/src/eval/py/runtime.ts) probes that + # path before falling back to PATH, so symlinking it here keeps PATH clean + # (no conflict with the python313 env in home/profiles/no-gui.nix) while + # guaranteeing kernel_gateway + ipykernel are importable without `omp setup + # python` ever needing to write to the store. + ompPythonEnv = pkgs.python3.withPackages (ps: [ + ps.ipykernel + jupyter-kernel-gateway + ]); + # Browser path for the playwright skill body. playwrightChromium = let @@ -144,6 +188,9 @@ in # main settings: ~/.omp/agent/config.yml (JSON is valid YAML) ".omp/agent/config.yml".text = builtins.toJSON ompSettings; + # see comment above ompPythonEnv definition. + ".omp/python-env".source = ompPythonEnv; + # model/provider config: ~/.omp/agent/models.yml ".omp/agent/models.yml".text = builtins.toJSON ompModels;