nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.56k stars 77 forks source link

error: infinite recursion encountered #242

Closed codygman closed 4 years ago

codygman commented 4 years ago

I think maybe I'm doing something wrong. Here is a very small repo to reproduce, but in short I have this:

let
  sources = import ./nix/sources.nix;
  lorriGit = import sources.nixpkgs { overlays = [ (import sources.lorri) ]; };
in lorriGit.lorri.version # BUG? returns "infinite recursion encountered" and I expected "1.1" or similar

and it returns:

[cody@nixos:~/code/niv-repro-infinite-recursion]$ nix-instantiate --eval minimal-niv-test.nix
error: infinite recursion encountered, at undefined position

I'm assuming I need to call the rust package builder on this maybe? The error doesn't make it obvious and my probably wrong assumption was that any source you added could just be built and was a nix derivation. Maybe a note in the docs if that isn't the case could help others who might have the same confusion.

nmattia commented 4 years ago

I had a look at the overlay you're trying to import and it appears to evaluate to a package (lorri). It means you can't just add it to your list of overlays but you must create an overlay, i.e. you say self: super: { lorri = ... }. Also, looks like the lorri package does not have a version attribute (it might be injected by nixpkgs in systemPkgs.lorri.version). I think this gives you what you want:

let
  sources = import ./nix/sources.nix;
  pkgs = import sources.nixpkgs
    {
      overlays = [
        (
          self: super:
            { lorri = import sources.lorri { pkgs = self; }; }
        )
      ];
    };
in
pkgs.lorri

When building it however I get a rust error:

error[E0599]: no method named `to_int_unchecked` found for type `f64` in the current scope
 --> <anon>:1:40
  |
1 | pub fn probe() { let _ = unsafe { 1f64.to_int_unchecked::<i32>() }; }
  |                                        ^^^^^^^^^^^^^^^^

error: aborting due to previous error

though the build seems to keep going. Let me know if it actually goes through.

codygman commented 4 years ago

Thank you! This works.