Nvim-treesitter and overrideAttrs not behaving as expected

I used to be able to override the nvim-treesitter package from nixpkgs (to a newer version) by doing the following:

  nvim-treesitter = pkgs.vimPlugins.nvim-treesitter.overrideAttrs (_: {
    version = "2023-03-27";
    src = pkgs.fetchFromGitHub {
      owner = "nvim-treesitter";
      repo = "nvim-treesitter";
      rev = "25dd24ed0e3b4456b1987cdd744e261be5dc6c7c";
      sha256 = "1rzg2dwrh536p2h341zrnam46gdfc3kkq60lvzqj7k1s4xymm377";
      fetchSubmodules = false;

In my home-manager configuration I reference it by doing the following:

        plugin = nvim-treesitter.withPlugins (
          plugins: with plugins; [
        config = builtins.readFile ../../config/nvim/plugins/treesitter.fnl;
        type = "fennel";

(This is definitely referencing the variable I defined earlier. It is not accidentally referencing pkgs.vimPlugins.)

I expected this to install my new derivation, but it always install the one from nixpkgs (2023-03-22 at the time of writing).

I’m 99% certain that this used to work, but it must’ve stopped working at some point in the past. Sadly I can’t pin down when exactly, because I only realized it stopped working yesterday (because of deprecation warnings in neovim).

I don’t know enough about the nix language itself to pin down why, but it looks like withPlugins returns the derivation from nixpkgs? Could this be because of the self in the withPlugins implementation?

How can I reference a newer version of nvim-treesitter and continue to use the niceties that the nixpkgs derivation provides?

nvim-treesitter.withPlugins now adds the tree sitter grammars to its dependencies. I’m not sure why home-manager doesn’t handle dependencies, you can use something like this to get around that.

1 Like

Thank you! The helped me to work around the issue.

I can now install my (slightly) more up-to-date version of nvim-treesitter and continue to use the parsers from/via nixpkgs.