This is a story about Pete
Pete likes to write Nix using Neovim
This is what happens to Pete:
- Pete commits changes his project repo.
- Pete wants to build and test his changes but must update the git revision and hash for Nix first.
- Pete doesn't use Nix well, so he just erases the old hash, and rebuilds, then copies the hash-mismatch error message and pastes it back into his config, then rebuilds again.
- Pete does this alot
because he is bad at developing software.
Don't be like Pete, use nix-prefetch.nvim!
nix-prefetch.nvim is currently limited to fetchFromGitHub attribute sets using a rev and hash value (See Future Development for planned features). As an example of a supported format, this is the code block to include nix-prefetch.nvim in your Nixvim config:
extraPlugins = [
(pkgs.vimUtils.buildVimPlugin {
name = "nix-prefetch.nvim";
src = pkgs.fetchFromGitHub {
owner = "pete3n";
repo = "nix-prefetch.nvim";
rev = "4f32441c3a7f550ccb8cbd73cba8ab11aa32f8d1";
hash = "sha256-FpUYNdyn3YrbrAWdkyeE7Kl/ThmSKBNl1l2ePjznKRc=";
};
})
];
This will register the NGUpdateRepo command which you can keybind. If you call NGUpdateRepo with the cursor in a fetchFromGitHub attribute set, then it will check for the most recent revision, and if it is different from the current, updates the revision and the corresponding hash.
- neovim v0.11+
- nvim-treesitter must be installed.
- nix-prefetch-git must be executable and available in your path.
To confirm dependencies are availabe, nix-prefetch includes a health check function that you can run from the nvim commandline with:
:checkhealth nix_prefetch
- fetchFromGitHub
- fetchFromGitLab
- update default branch to latest rev
- update from user specified rev
- update from user specified branch to latest rev
- nix-repl.nvim eval integration