hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
721 stars 41 forks source link

pre-commit.devShell usage? #136

Closed edrex closed 1 year ago

edrex commented 1 year ago

I'm adding a flake and pre-commit CI to a C/C++ project. nix flake check is working to run the hooks, but I can't figure out how to get an interactive shell to run them with the full tabular reporting. I see perSystem.pre-commit.devShell, but it doesn't seem to be exposed to the flake, and when I try something like

devShells.pre-commit = config.pre-commit.devShell;

in perSystem, I get

edrex@chip ~/s/g/a/way-displays (flake) [1]> nix run .#devShells.x86_64-linux.pre-commit
error: unable to execute '/nix/store/3ll7imw5xnr43gdzz7csxybzmjkni5pf-nix-shell/bin/nix-shell': Not a directory

For now I will just copy the body of that expression as a starting point.

edrex commented 1 year ago

Sorry, I'm still getting the hang of the module system.

The above does work, with nix develop .#pre-commit. The shellHook installs pre-commit hooks, rather than running them, but still good to know.