The presence of a hidden (starting with dot) file whose name matches the name of a package in the flake in the current directory, breaks nix {shell,build} .#the-package
.
Demo: I have a flake containing a package called aaa-and-bbb
which contains an executable aaa
which prints out This is program AAA.
$ pwd
/tmp/aaaaaargh
$ nix shell .#aaa-and-bbb -c aaa
This is program AAA.
$ touch .aaa-and-bbb
$ nix shell .#aaa-and-bbb -c aaa
error: --- BadURL -------------------------------------------------------------- nix
path '/tmp/aaaaaargh/.aaa-and-bbb' is not a flake (because it's not a directory)
In other words, nix .#aaa-and-bbb -c aaa
works fine, unless the file ./.aaa-and-bbb
exists.