Trouble with building PostgREST using nix-build

I have some modifications that I want to make to postgrest. PostgREST is written in Haskell, and uses nix for package management and setting up a testing environment. I’ve added new dependencies and I can’t get nix to build them. The project builds fine using cabal or stack. The docs recommend running the command nix-build --attr postgrestPackage, where postgrestPackage is a derivation defined in the default.nix file. The current default.nix file is defined here. When I run the build command, I get the following error:

Ready component graph:
    definite text-
        depends array-
        depends base-
        depends binary-
        depends bytestring-
        depends deepseq-
        depends ghc-prim-0.6.1
        depends template-haskell-
    This package indirectly depends on multiple versions of the same package. This is very likely to cause a compile failure.
      package binary (binary- requires bytestring-
      package text (text- requires bytestring-
Using Cabal- compiled by ghc-8.10
Using compiler: ghc-8.10.7
Using install prefix: /nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-
Executables installed in:
Libraries installed in:
Dynamic Libraries installed in:
Private executables installed in:
Data files installed in:
Documentation installed in:
Configuration files installed in:
No alex found
Using ar found on system at:
No c2hs found
No cpphs found
No doctest found
Using gcc version 10.3.0 given by user at:
Using ghc version 8.10.7 found on system at:
Using ghc-pkg version 8.10.7 found on system at:
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.24.2 found on system at:
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.68 found on system at:
Using hsc2hs version 0.68.7 found on system at:
Using hscolour version 1.24 found on system at:
No jhc found
Using ld found on system at:
No pkg-config found
Using runghc version 8.10.7 found on system at:
Using strip version 2.35 found on system at:
Using tar found on system at:
No uhc found
*** abort because of serious configure-time warning from Cabal
error: builder for '/nix/store/x3qd0sd1h1bjd6pfrb3cxgg0pkg225j1-text-' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/hyhianmkyv6y7v9yadyh311njw3lll97-okapi-' failed to build
error: 1 dependencies of derivation '/nix/store/z2gl26j25kgcsp3rrq74m54kabwvfymv-postgrest-' failed to build

The okapi package depends on text- text- depends on bytestring- and binary- binary- requires bytestring- and not bytestring- for some reason. This causes the build to fail because the project depends on two different versions of bytestring. The project builds when I use cabal or stack.

My question is, how do I fix this error I get from using nix-build? From my research: cabal is able to automatically find the right versions of packages to resolve dependencies, while nix can only have a single version of a package in a package set at a time. Using overrides to provide the specific version of a package from hackage didn’t work for me. I’m still confused about how overrides work in nix, and whether or not I should use overlays instead of overrides. How can I make it so that all of my dependencies depend on a single version of a package? Code is here.

Edit: I’m trying to build postgrest on a Digital Ocean server I use as a development machine. It’s running Ubuntu-20.04.

1 Like