How to package Neovim plugin with Python application

I’m trying to package GitHub - ms-jpq/coq_nvim: Fast as FUCK nvim completion. SQLite, concurrent scheduler, hundreds of hours of optimization.

The python package lists a few requirements, which can be installed imperatively through a Neovim command :COQDeps but I’d like to make things more Nix-y and have Nix handle the python requirements.

Important disclaimer: I’m not the author of the plugin and I know nothing about Python in general.

Here’s what I tried so far: GitHub - cideM/coq-nvim-nix

Since the flake is still fairly small, I’ll copy the code verbatim:

  description = "A very basic flake";

  inputs = {
    coq.url = "github:ms-jpq/coq_nvim";
    coq.flake = false;

    nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

    flake-utils.url = "github:numtide/flake-utils";

    mach-nix.url = "github:DavHau/mach-nix";

  outputs = { self, nixpkgs, coq, flake-utils, mach-nix }:
    flake-utils.lib.eachSystem ["x86_64-linux"] (system:
        pkgs = import nixpkgs { inherit system; };
        machNix = import mach-nix { inherit pkgs; };
      rec {
        packages = flake-utils.lib.flattenTree ({
          coq = machNix.mkPython {
            requirements = ''
            packagesExtra = [

          coqNeovimPlugin = pkgs.vimUtils.buildVimPluginFrom2Nix {
            name = "coq-nvim";
            version = "latest";
            src = coq;
            passthru.python3Dependencies = ps: [ packages.coq ];
        defaultPackage = packages.coq;

If I change

            passthru.python3Dependencies = ps: [ packages.coq ];


            passthru.python3Dependencies = ps: [ (ps.toPythonModule packages.coq) ];

and try to include this in my Neovim configuration I get

$ sudo nixos-rebuild switch --flake .
warning: Git tree '/home/tifa/dotfiles' is dirty
building the system configuration...
warning: Git tree '/home/tifa/dotfiles' is dirty
error: in pure evaluation mode, 'fetchTarball' requires a 'sha256' argument
(use '--show-trace' to show detailed location information)

The fact that I don’t get this error without the toPythonModule makes me wonder if, without toPythonModule, packages.coq isn’t actually evaluated as much as it should be.

In general though, I don’t really understand how any of this works. I got toPythonModule and the passthru thing from pkgs/misc/vim-plugins/overrides.nix in Nixpkgs and I more or less tried some random functions from mach-nix.

My theory is this:

  1. Adding the Neovim code from the plugin is easy and straight forward. It’s not the first Neovim plugin I’ve packaged
  2. The Python source code doesn’t need any special treatment, so that too should be taken care of by just using buildVimPluginFrom2Nix
  3. The Python dependencies on the other hand need to be made available to the Python package set and interpreter that Neovim is using

The third point is what I’m struggling with. I was hoping that mkPython would generate a folder where those dependencies can be found and that the passthru attribute would magically make things work.

I also tried using buildPythonApplication instead of mkPython but the source doesn’t include a so that doesn’t work.

Hi ! I am currently working on upstreaming the python dependencies of coq_nvim:

1 Like