Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

correct usage of extraPackages #530

Open
matdibu opened this issue Dec 5, 2024 · 1 comment
Open

correct usage of extraPackages #530

matdibu opened this issue Dec 5, 2024 · 1 comment

Comments

@matdibu
Copy link

matdibu commented Dec 5, 2024

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

@matdibu
Copy link
Author

matdibu commented Dec 5, 2024

I've tried printing the PATH from within that justfile

spell:
    tr ':' '\n' <<< "$PATH"

with this (ugly) hack

cspell = {
  enable = true;
  pass_filenames = false;
  extraPackages = [
    pkgs.just
    pkgs.nodePackages_latest.cspell
  ];
  entry = "${lib.getExe pkgs.just} spell";
};

but it looks like it includes neither just nor cspell

/nix/store/901c80rlps5q05bnjk1sj4zaz5k736nc-python3-3.12.7/bin
/nix/store/j877rdwz6hk0b4sz4d2blayc35vl4k0d-pre-commit-4.0.1/bin
/nix/store/j3s1h95x9z5jmh1j14ch9q962j0w7al3-python3.12-identify-2.6.1/bin
/nix/store/vjbdfb8y58mmnlv8wxf6hlacfz6zih03-python3.12-pytest-8.3.3/bin
/nix/store/943934n0x0vlg34krjll16ipykjxhdgl-python3.12-nodeenv-1.9.1/bin
/nix/store/jpxpwipk09alblka7sbhqs5vprabn5gv-python3.12-virtualenv-20.26.6/bin
/nix/store/r9gxdanbg938b9vimis7akyawkyb0yax-patchelf-0.15.0/bin
/nix/store/j44p1p9kci9rnrr3aj9a8j8rwvfmg75k-git-2.47.0/bin
/nix/store/sf6y4arqcm100rnnl3dhpg732i774zp6-coreutils-9.5/bin
/nix/store/psjqqbj19n3fqssn38hgz4cv7b7a9alp-findutils-4.10.0/bin
/nix/store/alq4bqllykgwrif112yqgrn9g001kn7b-diffutils-3.10/bin
/nix/store/13wxcn0j2wk911ahfkbvdq241rkprsv8-gnused-4.9/bin
/nix/store/nysgss3ggh3dv7mz08n28h29lazxhyc1-gnugrep-3.11/bin
/nix/store/1cd3p3kjh9c209s7832z8i3b8qcqggca-gawk-5.3.1/bin
/nix/store/cqyjb712c5q3axw9qjij05dnji2a7z48-gnutar-1.35/bin
/nix/store/qfc6wq1wpxvkkjqa6xr5685ip97qc3sr-gzip-1.13/bin
/nix/store/0kxxaix9l5dbih90491mv96zajsac57q-bzip2-1.0.8-bin/bin
/nix/store/iyrpqn6ana7j804dzis338n74kzznmj0-gnumake-4.4.1/bin
/nix/store/mm0pa3z7kk6jh1i9rkxqxjqmd8h1qpxf-bash-5.2p37/bin
/nix/store/3yv1shg4kg4ifkxzg2jgjsrrrd8s1w08-patch-2.7.6/bin
/nix/store/g0ih6cb93dm4n18bah982gsmayah3amy-xz-5.6.3-bin/bin
/nix/store/vkv9a83hknlnr7p2z8mwl16j5pb502gp-file-5.45/bin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant