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 = "44496fb3e706c795e87d475d674708919a01cbea";
hash = "sha256-tSDIGbTD+5fm1Qo3922DGJ1YIRNAUJF2btWf4kWbCoM=";
};
})
];
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.
nvim-treesitter must be installed. jq, and 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: update rev and hash
- fetchFromGithub: preserve rev, update hash
- sha256 attribute support
- version tag interpretation/support
- fetchFromGitLab support
- fetchurl support
- fetchzip support