Skip to content

cabal2nix integration? #468

@sellout

Description

@sellout

In commercialhaskell/stackage#7727 (comment), @sol suggested I run doctest more directly rather than having a test-suite doctests stanza in my Cabal file (which introduces ~75 lines of boilerplate per package). I started down that path, and then eventually remembered why I really run doctest as a test suite1.

Nixpkgs pulls in packages from Hackage (mostly via Stackage) and creates Nix derivations in a fairly standard way, using cabal2nix. These derivations run test-suites, but not doctest. So, to make sure my tests are run as part of the Nix packaging process, I wrap doctest in a test suite. This is a fairly common pattern for Nix-aware Haskell devs (e.g., from a package that isn’t mine: https://github.com/cdepillabout/termonad/blob/master/termonad.cabal#L156-L166).

I think this is more of a “discussion” than an “issue”, but I’m wondering what the future might look like here.

E.g., hackage2nix (part of cabal2nix) could potentially run cabal doctest on each package2, eliminating the need for the test suite, or doctest could provide some tooling to make the test suite approach less verbose.

I’m not sure what the right answer is, but this seems like a reasonable place to ask the question, and see what other ideas people have, and whether any other approaches already exist.

Footnotes

  1. This is made feasible by the cabal-doctest package (not to be confused with cabal-doctest in this repo, which adds a doctest subcommand to cabal).

  2. Maybe it could somehow identify the subset of packages that have doctests, or the Nixpkgs Haskell infra could include a blacklist of packages that shouldn’t have doctest run on them … or something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions