This feels a little dangerous, since these commands return incorrect values rather than erroring, and executables that are in the nix store may run these commands and may assume that they can do some from their pwd (ie, the store path at which the executable is stored). This is the situation that caught me out, as I was running some python utility code that over the course of its execution calls various nix functions.
I can’t reproduce it now either, at least not with nix build. Probably at this point it sounds like I was hallucinating, but this used up two hours of my morning today and definitely really happened. If I use nix eval on a flake, I still get something odd:
This only happens when the “florp/” string is not a flake reference, so the “/” is needed, but otherwise any string does this! It look like this is a bad interaction of Nix figuring out that realpath florp/ is /nix/store/2g3jazymqbjw9c390c3b7vw8xq3r8iny-hello-2.12.1/florp, then “building” that, making sure it exists.