Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nix doesn't use the flake inputs #3769

Closed
zimbatm opened this issue Jul 1, 2020 · 5 comments
Closed

Nix doesn't use the flake inputs #3769

zimbatm opened this issue Jul 1, 2020 · 5 comments

Comments

@zimbatm
Copy link
Member

zimbatm commented Jul 1, 2020

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
@kloenk
Copy link
Member

kloenk commented Jul 1, 2020

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

@edolstra
Copy link
Member

edolstra commented Jul 1, 2020

I agree, but it would be nice to have some syntax to use a flake input from another flake.

@edolstra
Copy link
Member

edolstra commented Jul 1, 2020

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).

@zimbatm
Copy link
Member Author

zimbatm commented Jul 1, 2020

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.

@edolstra
Copy link
Member

edolstra commented Jul 1, 2020

That should probably work without any wrapper scripts...

edolstra added a commit that referenced this issue Jul 1, 2020
This allows you to refer to an input from another flake. For example,

  $ nix run --inputs-from /path/to/hydra nixpkgs#hello

runs 'hello' from the 'nixpkgs' inputs of the 'hydra' flake.

Fixes #3769.
@edolstra edolstra closed this as completed Jul 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants