Nix evaluation cache a devshell during local development

I ran into this problem with the Nix Flakes evaluation cache where it always rebuilds a devshell if the git repository is dirty, even though the devshell does not depend on what was edited. Here’s a minimal reproduction of it:

The one workaround I’ve found so far is to move the devshell configuration into it’s own git repository, but this feels a bit extreme. I also tried using nix-direnv, but it rebuilt the shell every time still.

Are there any other workarounds for this issue?

I came up with another workaround. If you do

nix develop git+file://${PWD}?ref=HEAD

then you only have to rebuild your dev shell once per commit.

If I understand correctly, using GitHub - nix-community/nix-direnv: A fast, persistent use_nix/use_flake implementation for direnv [maintainer=@Mic92 / @bbenne10] will also cache the evaluation

1 Like