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

niv can't be used to pin NixOS #113

Closed
hyperfekt opened this issue Aug 5, 2019 · 9 comments
Closed

niv can't be used to pin NixOS #113

hyperfekt opened this issue Aug 5, 2019 · 9 comments

Comments

@hyperfekt
Copy link

hyperfekt commented Aug 5, 2019

When pinning NixOS by setting nixpkgs in the $NIX_PATH to a file that imports nixpkgs from sources.nix, an infinite recursion will be entered because niv believes it has nixpkgs available and tries to use fetchers from the nixpkgs version it is supposed to fetch.

@nmattia
Copy link
Owner

nmattia commented Aug 6, 2019

This is a [never](#39 ending issue, and I still do not have a good solution unfortunately :(

However I've used it successfully with NixOS; can you share your setup?

@hyperfekt
Copy link
Author

hyperfekt commented Aug 6, 2019

You probably had that file in the same directory as sources.nix, which is not the case for me since it is part of a larger config. I might be wrong about this, but I think with sources.nix being in the nix subdirectory the hasThisAsNixpkgsPath function will almost never return true.
I might be wrong about this, but I think to evaluate NixOS a number of files are directly accessed in different subdirectories, which all have to import nixpkgs, so it doesn't seem possible to put them all in the same (super)directory as/of sources.nix anyhow.

@hyperfekt
Copy link
Author

Here is how I pin NixOS: nixpkgs in the $NIX_PATH points to this folder.
I've changed hasThisAsNixpkgsPath in the sources.nix to always return true for now.

@nmattia
Copy link
Owner

nmattia commented Aug 7, 2019

The assumption is that "most of the time" there will be a ./nix/default.nix next to the ./nix/sources.nix, maybe we should provide a config file that specifies

  1. where the source.nix is
  2. whether or not to import <nixpkgs> for the fetchers
    ?

@leotaku
Copy link
Contributor

leotaku commented Aug 7, 2019

@nmattia I think having an additional config file wouldn't be the greatest thing. What I instead would like to see is a well-commented and easily understandable (for newcomers to Nix) sources.nix file.

Possibly the "logic" of the file could also be moved to a different .nix file, so that a new user can just set some simple parameters (like with a traditional config file), while advanced users still have full access to the power of Nix.

@michaelpj
Copy link
Contributor

You can explicitly use builtin fetchers now. I recommend doing this for your nixpkgs pins especially.

@hyperfekt
Copy link
Author

hyperfekt commented Aug 7, 2019

You can explicitly use builtin fetchers now. I recommend doing this for your nixpkgs pins especially.

Good point, seems I mistraced the variable dependencies of the functions used to call the builtins inside sources.nix. I guess that solves the issue.

@nmattia
Copy link
Owner

nmattia commented Aug 8, 2019

@michaelpj ok I'm lost, how does one enable the builtins nixpkgs?

@michaelpj
Copy link
Contributor

Just change the type of the nixpkgs pin to builtin-tarball instead of tarball and it will work fine. I set up an example like the one described in the issue and I get infinite recursion with tarball (for the reasons explained) and it works fine with builtin-tarball.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants