Skip to content

How to resolve recursive library/test dependencies in Haskell? #34110

Closed

Description

@kirelagin

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?

Activity

  1. kirelagin commented on Apr 28, 2018

    @kirelagin
    MemberAuthor

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

  2. peti commented on Apr 29, 2018

    @peti
    Member

    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.

  3. changed the title [-]Keep Haskell libraries and tests separately[/-] [+]How to resolve recursive library/test dependencies in Haskell?[/+] on Apr 29, 2018
  4. added
    0.kind: question
    6.topic: haskell
    on Apr 29, 2018
  5. kirelagin commented on May 1, 2018

    @kirelagin
    MemberAuthor

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

  6. peti commented on May 4, 2018

    @peti
    Member

    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.

  7. Ericson2314 commented on May 4, 2018

    @Ericson2314
    Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: question6.topic: haskell

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions