Recently, I wanted to add a Neovim plugin to nixpkgs, so I can then add it to NixVim. I tried following the guide from the docs.

However, I kept getting the following errors:

nix-shell -p vimPluginsUpdater --run vim-plugins-updater
error:
while calling the 'derivationStrict' builtin

         at /builtin/derivation.nix:9:12: (source not available)

while evaluating derivation 'shell'
         whose name attribute is located at /nix/store/whhzjfgalghpm34irclh01c0afynmyll-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:300:7

while evaluating attribute 'buildInputs' of derivation 'shell'

         at /nix/store/whhzjfgalghpm34irclh01c0afynmyll-nixpkgs/nixpkgs/pkgs/stdenv/generic/make-derivation.nix:347:7:

          346|       depsHostHost                = lib.elemAt (lib.elemAt dependencies 1) 0;
          347|       buildInputs                 = lib.elemAt (lib.elemAt dependencies 1) 1;
             |       ^
          348|       depsTargetTarget            = lib.elemAt (lib.elemAt dependencies 2) 0;

       error: undefined variable 'vimPluginsUpdater'

       at «string»:1:107:

            1| {...}@args: with import <nixpkgs> args; (pkgs.runCommandCC or pkgs.runCommand) "shell" { buildInputs = [ (vimPluginsUpdater) ]; } ""

Or I was getting 429 network errors, too many requests to GitHub.

Solution

I found this great person who was able to solve my issue on discourse. Assuming you have a fork of nixpkgs and have to clone it locally, i.e. git clone https://github.com/hmajid2301/nixpkgs.git

  1. Update nixpkgs/pkgs/applications/editors/vim/plugins/vim-plugin-names
  2. Can do this using the ./update.py add "gbprod/yanky.nvim" (where gbprod/yanky.nvim is the path to git repository)
  3. Export your GitHub Personal Token
  4. You can create one by following this link
  5. export GITHUB_API_TOKEN=your_token
  6. I will do a post in the future about how you can do this in fish shell and keep secrets out of your shell history.
  7. nix-shell -I nixpkgs=channel:nixpkgs-unstable -p vimPluginsUpdater --run vim-plugins-updater
  8. Make sure to run this in the repository root
  9. Push your changes and create a PR with nixpkgs repo
  10. You will likely need to rebase your commits to follow the contribution guidelines, check those when creating the PR

That’s it! I am not sure if this will be useful for others (I will most likely reference this myself in the future), but that’s the easiest way I found to add new vim plugins to nixpkgs.