cabal icon indicating copy to clipboard operation
cabal copied to clipboard

Add a `cabal vendor` command

Open philderbeast opened this issue 7 months ago • 6 comments

Describe the feature request Add a cabal vendor command that vendors dependencies automatically.

Additional context From a question on how to do automatic vendoring with cabal, #10934.

philderbeast avatar Apr 22 '25 10:04 philderbeast

Similar features in other languages:

cargo-vendor - Vendor all dependencies locally go vendoring - Vendoring may be used to allow interoperation with older versions of Go, or to ensure that all files used for a build are stored in a single file tree.

philderbeast avatar Apr 22 '25 10:04 philderbeast

This will be a great feature for Linux distribution maintainers.

lRespublica avatar Apr 22 '25 11:04 lRespublica

Is that really true? Most distros tend to prefer to package dependencies their way instead of vendoring, from what I've seen.

geekosaur avatar Apr 22 '25 21:04 geekosaur

At the very least, because there is currently no native support for this functionality?

In my ALT Linux RPM packages, I use the cabal-vendor script, which fetches all dependencies and creates a local repository. Other distributions that also lack a workflow for handling dynamic dependencies might consider adopting a similar approach but in native way.

lRespublica avatar Apr 23 '25 15:04 lRespublica

I think it could be interesting for some applications of distro packaging, so I would welcome such a feature if it worked well, with eventual hope of moving from v1/Setup to use offline cabal-install for distro building with vendoring (or bundling as we tend to call it in Fedora - to me vendoring is really modified tarballs/sources, but I know it widely used without that meaning necessarily).

Overall it is getting very expensive to binary package and further maintain all Haskell dependencies individually. So having a simple way to package Haskell in a self-contained way could be attractive.

In my Fedora Copr repos (non-official Fedora packages) I often use cabal install to package things like HLS etc.

For example Fedora Rust uses cargo to build official fedora rust library packages (offline) - even though they only ship source library crates now not binaries files.

juhp avatar May 02 '25 13:05 juhp

I also need something like this for https://sr.ht/~fgaz/nix-build-cabal-project/

All the existing ways to fetch and vendor all dependencies have issues:

  • One way is to set remote-repo-cache: /path/to/vendor in the cabal config, run cabal update, make cabal-install fetch the dependencies in one of the following ways, and cabal get all packages to get the revised .cabal files.
    • cabal build --only-dependencies will download exactly what is necessary for cabal to build the project provided the index is also present. This is a problem for me because the index is not reproducible (unless you manually truncate the tarball to the desired index-state but that's a bit messy) and also really large. EDIT: This can also be worked around by using plan.json as the source of the list of .cabal files to cabal get.
    • cabal fetch . fetches everything but only works for single packages, not projects (#10977)
  • The other way is to use an external tool, but that's difficult to do because plan.json does not contain revision information (#6186). You'd have to replicate a lot of cabal-install logic or depend on the (rapidly changing) cabal-install library

I plan to work a bit on the above issues at Zurihac

fgaz avatar Jun 07 '25 13:06 fgaz

@fgaz have you had a chance to work on this further? I’d be very interested to see what you came up with.

lRespublica avatar Jul 10 '25 15:07 lRespublica