I've been seeing that nix develop takes a very long time on large projects, and I believe it's due to the whole folder being copied to the store.
nix-shell doesn't have this problem, but I need flakes specifically because they allow to have runtime libraries, which shell doesn't seem to support. (Translating flake.nix to a shell.nix exactly has different execution results.)
What can I do? I've tried putting the flake.nix on an empty subfolder, and it solves it, but it's extremely tedious and clunky.
One can have a
shell.nixthat uses theflake.nixin a subdir. Here's how one can do this:in
shell.nix:in
./nix/flake.nix:Or whatever your flake is. Mostly important that we have
flake-compat.Then do a
nix flake updateand ensure thenix/flake.lockfile exists. At that pointnix-shell(in the repo root) will start working but will use thenix/flake.nixcontent, and only copy files innix/into the store. This does limit to some extent what the flake can do, but for manydevShelluses it's sufficient.