The problem you’re seeing is caused because nixpkgs only contains one version of a given dependency (in some cases multiple versions), but cabal
knows about all versions of your dependencies and has a solver built-in to figure out which version to use.
For example, nixpkgs might only contain a derivation for lens-4.18.0
. Since that doesn’t meet the version you require in creatur-wains.cabal
, nix-build
just fails.
However, when building with cabal
, cabal
looks on Hackage and sees that there is a lens-4.19.0
(or whatever) available and downloads and uses that.
The easiest solution is to either relax the version bounds for the lens
dependency in your creatur-wains.cabal
file, or to override the nixpkgs version of lens
in your release.nix
file (with a function like callHackage
).
This isn’t related to the problem you’re seeing above, but I’d also suggest you use the callCabal2nix
function to build your own packages in your release.nix
file, instead of generating the creatur.nix
, etc files by hand with cabal2nix
and using callPackage
on them.
See Nix Haskell Development (2020) for some more suggestions.