Describe the bug
When running nix shell nixpkgs#hello in a repository that contains a flake.nix and flake.lock files, I would expect Nix to use the version of nixpkgs that is specified in the lock file. Instead, it sources it from the latest registry version.
This means that every time the flake TTL is reached, Nix will try and pull the latest registry and maybe get a different version of the package. I would prefer if I was able to pin and control when that version gets updated for a particular project.
Workaround
It's possible to re-export nixpkgs in the flake and then access it, for example with nix shell .#nixpkgs.hello.
While this is possible, I think that it would be more convenient to get access to the underlying inputs directly. That will make debugging easier for example.
nix-env --version output
nix-env (Nix) 2.4pre20200521_00b562c
I don't see it as a bug, but as an expected behavior. I think this behavior would confuse if running nix shell from different dirs creates a different shell
I agree, but it would be nice to have some syntax to use a flake input from another flake.
Here's an idea: we could have a flag that overrides the registry using the lock file entries from the specified flake. E.g.
$ nix run --override-from . nixpkgs#hello
I.e. the registry entry for nixpkgs would be set to the nixpkgs input from the flake in the current directory.
This could have other uses, like copying lock file entries from another flake (e.g. nix flake update --override-from /path/to/other/flake --update-input nixpkgs).
I like that idea. This would also allow me to write a wrapper script that can search-up for the flake.lock file so that nix build can be called anywhere from within that repository.
That should probably work without any wrapper scripts...
Most helpful comment
Here's an idea: we could have a flag that overrides the registry using the lock file entries from the specified flake. E.g.
I.e. the registry entry for
nixpkgswould be set to thenixpkgsinput from the flake in the current directory.This could have other uses, like copying lock file entries from another flake (e.g.
nix flake update --override-from /path/to/other/flake --update-input nixpkgs).