NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.15k stars 14.18k forks source link

Documentation: callCabal2Nix #251884

Open ScottFreeCode opened 1 year ago

ScottFreeCode commented 1 year ago

Problem

Nix has a very nice callCabal2nix function that can wrap a Haskell project and provide the dependencies for it without having to change the Haskell project, which remains the source of truth.

When I figured this out, I couldn't actually find documentation for this anywhere. It doesn't even come up in https://haskell4nix.readthedocs.io/search.html?q=callCabal2Nix&check_keywords=yes&area=default

Proposal

We could do with, at the very least, some minimal examples like https://gist.github.com/ScottFreeCode/9b0ea3e52fa56c93ea8ca14791e55bb4

(I'm not 100% certain the monorepo ones are correct in terms of publishing the packages. And I haven't begun to figure out things like how to control the compiler version, say if you want to avoid that one GNU library, or cross compile, or whatever.)

Checklist

futu2 commented 1 year ago

True. Suffered a lot. A few of tutorials but each only mentioned some part of usage, likes, https://bytes.zone/posts/callcabal2nix/

btw, where can I find the source code of callCabal2nix?

amuricys commented 10 months ago

@futu2 here: https://github.com/NixOS/nixpkgs/blob/master/pkgs/development/haskell-modules/make-package-set.nix#L225