git-hooks.nix
git-hooks.nix copied to clipboard
correct usage of extraPackages
I'm trying to add a few extra packages to the environment of a hook, and I've tried using extraPackages, but it only adds them to the nix develop shell, not the hook itself
cspell = {
enable = true;
pass_filenames = false;
extraPackages = [
pkgs.just
];
entry = "just spell";
};
spell:
cspell lint --unique --no-progress --no-summary --show-context .
$ nix flake check --print-build-logs
pre-commit-run> Running: $ pre-commit run --all-files
pre-commit-run> cspell...................................................................Failed
pre-commit-run> - hook id: cspell
pre-commit-run> - exit code: 1
pre-commit-run> Executable `just` not found
it looks like the package is included within the dev shell
devShells.pre-commit = config.pre-commit.devShell;
$ which just
which: no just in (/run/wrappers/bin:/home/mateidibu/.nix-profile/bin:/nix/profile/bin:/home/mateidibu/.local/state/nix/profile/bin:/etc/profiles/per-user/mateidibu/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin)
$ nix develop .#pre-commit
$ which just
/nix/store/ian74ppvb1z7ykc72l7lsxlfpz08b19v-just-1.36.0/bin/just
removing pkgs.just from pre-commit.settings.hooks.cspell.extraPackages removes it the dev shell as well, as expected