cabal
cabal copied to clipboard
Add a `cabal vendor` command
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.
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.
This will be a great feature for Linux distribution maintainers.
Is that really true? Most distros tend to prefer to package dependencies their way instead of vendoring, from what I've seen.
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.
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.
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/vendorin the cabal config, runcabal update, make cabal-install fetch the dependencies in one of the following ways, andcabal getall packages to get the revised.cabalfiles.cabal build --only-dependencieswill 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 usingplan.jsonas the source of the list of.cabalfiles tocabal 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.jsondoes 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 have you had a chance to work on this further? I’d be very interested to see what you came up with.