Nixpkgs: How to resolve recursive library/test dependencies in Haskell?

Created on 21 Jan 2018  路  5Comments  路  Source: NixOS/nixpkgs

Suppose I have two packages: lib and test-util. The test-util library depends on the lib library and the tests of lib depend on the test-util library. I have created an example of such a project and it works just fine with stack test.

stack2nix (or cabal2nix) produces an expression that separates the dependencies into libraryHaskellDepends and testHaskellDepends but then the builder concatenates everything together and it results in a cycle.

Would it be possible to produce separate derivations for the library and for its tests and then probably combine them into a single derivation to preserve the old behaviour?

question haskell

Most helpful comment

Okay. Apparently I misunderstood your example. In that case, just do the overrides the other way round. Pass a dontCheck lib version to test-util for the build, then use that to build a tested version of lib.

All 5 comments

Bump! Any ideas on how this can be solved?
(@peti)

You can pass the lib build a version of test-util that has its test suite disabled, i.e.

lib = callPackage ./lib.nix { test-util = dontCheck self.test-util; };
test-util = callPackage ./test-util.nix { };

This will use an untested version of test-util to build a tested lib, and then that version will be used to build a tested test-util.

Hm, I鈥檓 not sure how this can help, as test-util doesn鈥檛 have any tests anyway. It consist only of a library and it is its library that depends on lib.

Okay. Apparently I misunderstood your example. In that case, just do the overrides the other way round. Pass a dontCheck lib version to test-util for the build, then use that to build a tested version of lib.

@peti's trick is indeed the proper short-term solution. But I maintain that in the long term, separate per-component derivations is simplest correct-by-construction way to go.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chris-martin picture chris-martin  路  3Comments

ob7 picture ob7  路  3Comments

ayyess picture ayyess  路  3Comments

grahamc picture grahamc  路  3Comments

tomberek picture tomberek  路  3Comments