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-1.2.5.0-FFCfNn1f2bA9PXrEXtashE
        depends array-0.5.4.0
        depends base-4.14.3.0
        depends binary-0.8.8.0
        depends bytestring-0.10.12.1-DpRHi4GJKYaInY8EXvYWJ3
        depends deepseq-1.4.4.0
        depends ghc-prim-0.6.1
        depends template-haskell-2.16.0.0
Warning:
    This package indirectly depends on multiple versions of the same package. This is very likely to cause a compile failure.
      package binary (binary-0.8.8.0) requires bytestring-0.10.12.0
      package text (text-1.2.5.0) requires bytestring-0.10.12.1-DpRHi4GJKYaInY8EXvYWJ3
Using Cabal-3.2.1.0 compiled by ghc-8.10
Using compiler: ghc-8.10.7
Using install prefix: /nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0
Executables installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/bin
Libraries installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/lib/ghc-8.10.7/x86_64-linux-ghc-8.10.7/text-1.2.5.0-FFCfNn1f2bA9PXrEXtashE
Dynamic Libraries installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/lib/ghc-8.10.7/x86_64-linux-ghc-8.10.7
Private executables installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/libexec/x86_64-linux-ghc-8.10.7/text-1.2.5.0
Data files installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/share/x86_64-linux-ghc-8.10.7/text-1.2.5.0
Documentation installed in:
/nix/store/5kjfm2cdb0b0fvr99320r9izlb2rgbkd-text-1.2.5.0-doc/share/doc/text-1.2.5.0
Configuration files installed in:
/nix/store/4z138ni131r0iwsi9zgk3jbg87s78s77-text-1.2.5.0/etc
No alex found
Using ar found on system at:
/nix/store/a4mmjm3bblxwp8h53bcfx3dly80ib0ba-binutils-2.35.1/bin/ar
No c2hs found
No cpphs found
No doctest found
Using gcc version 10.3.0 given by user at:
/nix/store/s5hkav7whndbfz0szshpb46h4idqdq9a-gcc-wrapper-10.3.0/bin/gcc
Using ghc version 8.10.7 found on system at:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/ghc
Using ghc-pkg version 8.10.7 found on system at:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.24.2 found on system at:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/haddock
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:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/hpc
Using hsc2hs version 0.68.7 found on system at:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/hsc2hs
Using hscolour version 1.24 found on system at:
/nix/store/b7v1wg1g9dyiic04q836k4s33cmrfnm9-hscolour-1.24.4/bin/HsColour
No jhc found
Using ld found on system at:
/nix/store/5d5j1z9bg01wqxahihy2x5n22ykc32w8-binutils-wrapper-2.35.1/bin/ld.gold
No pkg-config found
Using runghc version 8.10.7 found on system at:
/nix/store/673ic4dsw35wmqwq59z821l67fjfix8w-ghc-8.10.7/bin/runghc
Using strip version 2.35 found on system at:
/nix/store/a4mmjm3bblxwp8h53bcfx3dly80ib0ba-binutils-2.35.1/bin/strip
Using tar found on system at:
/nix/store/nwg8in201f7y6vdm787v3j84jjrn0ayw-gnutar-1.34/bin/tar
No uhc found
*** abort because of serious configure-time warning from Cabal
error: builder for '/nix/store/x3qd0sd1h1bjd6pfrb3cxgg0pkg225j1-text-1.2.5.0.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/hyhianmkyv6y7v9yadyh311njw3lll97-okapi-0.1.0.2.drv' failed to build
error: 1 dependencies of derivation '/nix/store/z2gl26j25kgcsp3rrq74m54kabwvfymv-postgrest-9.0.0.20220516.drv' failed to build

The okapi package depends on text-1.2.5.0. text-1.2.5.0 depends on bytestring-0.10.12.1-DpRHi4GJKYaInY8EXvYWJ3 and binary-0.8.8.0. binary-0.8.8.0 requires bytestring-0.10.12.0 and not bytestring-0.10.12.1-DpRHi4GJKYaInY8EXvYWJ3 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