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