arch-hs icon indicating copy to clipboard operation
arch-hs copied to clipboard

Use cabal to resolve dependencies

Open poscat0x04 opened this issue 5 years ago • 3 comments

When you call cabal configure inside a cabal project, cabal will automatically resolve dependencies and produce a file representing the build plan called plan.json under the directory dist-newstyle/cache. There are some advantages to using plan.json over the current method:

  1. No need to reimplement dependency resolution
  2. cabal resolves dependencies separately for different components (library, sub-libraries, executables, tests, benchmarks)

poscat0x04 avatar Dec 10 '20 12:12 poscat0x04

Haven't seen you for a long time >_<

Actually, I didn't aware that cabal can produce plan.json -- which describes the dependency information, and can be operated by cabal-plan -- until a while after I finished the main part of arch-hs. It's good to use an existing solution, instead of reimplementing the entire dependency resolution. But noticed that cabal solver is a internal part of cabal-install, which does not provide publid API. This would let arch-hs depends on cabal-install, which seems not quite reasonable. Moreover, arch-hs currently does not consider the version constraint of packages during the dependency resolution, so it does something like "collecting" dependencies, rather than "resolving" dependencies. This does have advantages. According to the Arch Linux packaging principle, we always follow the latest version of packages. If a set of packages are not buildable due to the version bounds or compatibility, we should fix those problematic packages before distribute them. Thus, conventional SAT solver does not make a lot of sense here. BTW, arch-hs resolves five types of components as well, then makes libraries, sub-libraries, and executables become depends, tests become makedepends.

berberman avatar Dec 10 '20 12:12 berberman

arch-hs works fine now, but a full-featured SAT solver can make contribution to checking the consistency of target packages, i.e. it would warn us if there is no available build plan, so that we can know some packages need to be fixed before we actually build them. I'm glad if you could help me refactor the project.

berberman avatar Dec 10 '20 15:12 berberman

True. I have been working on a rewrite of cabal2nix (that adds many features) recently. I stumbled into your repo while searching for a good way of doing dependency resolution. After some research, my conclusion is that it's just too much of a hassle to reimplement cabal-install's solver. That was just my two cents :)

poscat0x04 avatar Dec 13 '20 13:12 poscat0x04