nix-community / nix-index

Quickly locate nix packages with specific files [maintainers=@bennofs @figsoda @raitobezarius]
Other
817 stars 50 forks source link

`PackagesQuery::iter` doesn't fail on error #187

Open edude03 opened 2 years ago

edude03 commented 2 years ago

I've been hacking on this today "in anger" because I was trying to get nix-index working on my m1 mac but it doesn't due to haskellPackages not evaluating:

$ nix-env -qa -f '<nixpkgs>' -A haskellPackages --xml
error: attribute 'streamly_0_8_1_1' missing

       at /nix/store/1plvwhmv48whaypzixdlahjvwv19nz7h-nixpkgs/nixpkgs/pkgs/development/haskell-modules/configuration-darwin.nix:259:6:

          258|     ] ++ (drv.libraryFrameworkDepends or []);
          259|   }) super.streamly_0_8_1_1;
             |      ^
          260|

I figured I could quickly jump in and make nix-index ignore sets that don't evaluate however, it ends up in an infinite loop when the parser fails.

I'm not sure exactly what the intention here was:

https://github.com/bennofs/nix-index/blob/e7c66ba52fcfba6bfe51adb5400c29a9622664a2/src/nixpkgs.rs#L112-L136

But in case of an error, it returns Some(Err), which tells rust there are more items in the iter.

as a quick hack to test my theory I added something like

if let Some(Err(_)) = opt {
  return None
}

opt

which works, but I'm not sure what the proper solution is.