cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
3.56k stars 259 forks source link

Pre-commit hook packages can conflict/override language packages #1103

Closed sandydoo closed 1 month ago

sandydoo commented 1 month ago

Describe the bug

If you pin a language package with languages.elixir.package = pkgs.elixir_1_14 and enable a pre-commit hook that uses a different version of the same package, which package you get in the shell might not be what you expect.

It looks like the newly added enabledPackages in pre-commit can override the pinned language packages. Users may be caught off-guard by this.

See https://discord.com/channels/1036369714731036712/1147538583134158953/1225807821334122527

To reproduce

{
  languages.elixir.enable = true;
  languages.elixir.package = pkgs.elixir_1_14;
  pre-commit.hooks.mix-format.enable = true;
}

Result:

➜ which elixir
/nix/store/syj2k0njckc0nx6v4zm0zd9dh6b62n3q-elixir-1.15.7/bin/elixir

Expected:

➜ which elixir
/nix/store/aci58vjsd2apqza8nb8f86wwxc21hwn4-elixir-1.14.5/bin/elixir

Version

v1.0.2 >=

sandydoo commented 1 month ago

In the meantime, you can use the following workaround:

{
  pre-commit.hooks.mix-format.enable = true;
  pre-commit.hooks.mix-format.package = pkgs.elixir_1_14;
}