Build of Haskell package 'lapack' fails because of missing 'random-1.1'

I try to understand failure of buildung some Haskell packages and how to fix them. For instance:

$ nixpkgs> nix-build --no-out-link -A haskellPackages.lapack --arg config '{ allowBroken = true; }'
Setup: Encountered missing or private dependencies:
random ==1.1.*

builder for '/nix/store/iy7fbcxxhndcnrpp99cb6nlmyr58nh84-lapack-0.3.2.drv' failed with exit code 1

Why does Nix choose random-1.1? lapack itself does not depend directly depend on random, but its dependency QuickCheck does.

In contrast I can build lapack-3.2 using stack build lapack. So in Stackage it seems to be correct, but it seems not to be adopted by Nix.

The Haskell ecosystem in Nixpkgs generally follows either the latest LTS, or Stackage Nightly.

Currently, master and haskell-updates are on LTS-18, which has random-1.2.0. So haskellPackages.random is random-1.2.0.

The Haskell builder in Nixpkgs doesn’t have a solver (unlike cabal-install), so Nix isn’t really “choosing” random-1.2.0. random-1.2.0 is just the version currently in haskellPackages.

This is quite hard to tell from lapack: Numerical Linear Algebra using LAPACK, but lapack does actually depend on random in the lapack-test component:

There are a couple things to keep in mind here:

  1. If you don’t tell us what resolver stack ends up using, it is hard for anyone to verify this. stack could end up picking some really old LTS (like LTS-6 or something). But that doesn’t really help us, since Nixpkgs is on LTS-18.
  2. stack doesn’t build and run tests when you try to install an arbitrary package. The Nixpkgs Haskell stuff does. This random problem appears to be caused in the tests.

So how to get lapack building?

Since lapack-0.3.2 is in LTS-18, my first guess would be to just disable the tests:

$ nix repl ./.
nix-repl> :b haskell.lib.compose.dontCheck (haskell.lib.compose.markUnbroken haskellPackages.lapack)

this derivation produced the following outputs:
  doc -> /nix/store/mk6s49a6dl0spkdrkmw1xjw15v0f59dw-lapack-0.3.2-doc
  out -> /nix/store/3lb0p26z2gqb753crf7pfzgnrpvwkspp-lapack-0.3.2

It looks like we got lucky and this worked!

It would be really great if you could send a PR to the haskell-updates branch in Nixpkgs adding this fix.

Basically, you just have to do the following two things:

  1. Remove lapack from the list of broken packages: nixpkgs/broken.yaml at e31f392946cfce8a6ded8716f438bf670b0ce0da · NixOS/nixpkgs · GitHub
  2. Add an override saying not to run lapack's tests. Similar to a line like nixpkgs/configuration-common.nix at e31f392946cfce8a6ded8716f438bf670b0ce0da · NixOS/nixpkgs · GitHub, but for lapack.

I am sure we can also make the tests work.

How can I achieve that Nix uses random-1.2 for the tests?

How can I achieve that Nix uses random-1.2 for the tests?

The lapack-0.3.2 .cabal file has a constraint on random ==1.1, so the easiest way is to jailbreak lapack.

Check through nixpkgs/configuration-common.nix at e31f392946cfce8a6ded8716f438bf670b0ce0da · NixOS/nixpkgs · GitHub for uses of doJailbreak.

Alternatively, you may be interested in trying the later version of lapack, which you can find at haskellPackages.lapack_0_4. It is possible this may not need a doJailbreak or dontCheck. I haven’t tried this at all.

1 Like