Nix develop <path-to-profile> doesn't start the already built shell?

Hi all

Looking at the Wiki (ex: nix develop - Nix 2.28.5 Reference Manual) in particular these statements:

Record a build environment in a profile:
$ nix develop --profile /tmp/my-build-env nixpkgs#hello
Use a build environment previously recorded in a profile:
$ nix develop /tmp/my-build-env

my understanding is that we should be able to build+enter shell with the first command, and store the shell “dump” into the profile; and my understanding of the second part is that we could “load” the shell (immediately, without “rebuilding” it) by launching the second command.
Also in some places it seems to confirm what I’m expecting from “nix develop” (ex: How are you keeping devshell dependencies live in store? - #5 by edolstra)

However, that doesn’t seem to be the case: when I run the second command, nix hangs building something (but I don’t know what).
In very verbose mode, here are the first lines of what nix develop does:

$ cat /nix/store/23sjim3h7njh5ijzaadnlkrci6blw1sc-my-build-env
{
“bashFunctions”: {
“_activatePkgs”:" \n local …

$ nix develop -vvv /nix/store/23sjim3h7njh5ijzaadnlkrci6blw1sc-my-build-env
evaluating file ‘<nix/derivation-internal.nix>’
evaluating derivation ‘flake:nixpkgs#bashInteractive’

And so, nix start downloading nixpkgs rev etc…

Am I misunderstanding the “nix develop ” behavior ?

Note: I’m using “nix (Nix) 2.28.3”

Thanks all for any feedback

I don’t fully understand it, but vaguely:

  1. nix develop command hard-codes its entry point as nixpkgs#bashInteractive. See nix/src/nix/develop.cc at 7caac53ae47100e10d836fbd194ed45e83c467fe · NixOS/nix · GitHub

  2. Therefore, each time you run nix develop, it re-evaluates nixpkgs#bashInteractive

I may have run into a similar issue: mkShell overrides diffutils overrides?

Perhaps @dramforever or @emily can chime in to comment on what I said?

But I don’t understand the downloading part… Sure, it can take a while to eval bashInteractive etc., but re-downloading each time? I have no idea.

Thanks for your reply.

Sorry my question was unclear, and maybe more about: why is the second command (“nix develop ”) even building something ? Why isn’t it just sourcing the content of the file to load the environment, without building anything ?