tweag / opam-nix

Turn opam-based OCaml projects into Nix derivations
MIT License
109 stars 32 forks source link

Support `opam-nix-gen` picking up mutliple packages in the same project #37

Closed RyanGibb closed 1 year ago

RyanGibb commented 1 year ago

Is your feature request related to a problem? Please describe.

My motivation is picking up vendored dependencies in materialization.

Describe the solution you'd like

For opam-nix-gen support picking up multiple packages in the same project.

An materializeOpamProject' could be useful for this. Something like:

  materializeOpamProject' = { repos ? [ opamRepository ], resolveArgs ? { }
    , regenCommand ? null, pinDepends ? true, recursive ? false }:
    name: project: query:
    let
      repo = makeOpamRepo' recursive project;
      latestVersions = mapAttrs (_: last) (listRepo repo);

      pinDeps = concatLists (attrValues (mapAttrs
        (name: version: getPinDepends repo.passthru.pkgdefs.${name}.${version})
        latestVersions));
    in materialize {
      repos = [ repo ] ++ optionals pinDepends pinDeps ++ repos;
      resolveArgs = { dev = true; } // resolveArgs;
      inherit regenCommand;
    } (llatestVersions // query);

Describe alternatives you've considered

A workaround is to just ignore these vendored dependencies and rely on dune to pick them up when building.

However if the vendored dependencies are modified to depend on an additional package these won't be picked up and will have to manually be added to the query.

Additional context

I came about this limitation while working on https://github.com/RyanGibb/aeon, which has dependencies vendored: https://github.com/RyanGibb/aeon/tree/e28f84281886394e81ba07076de21b3725aa7eec/duniverse.

balsoft commented 1 year ago

Would you be willing to make a PR with this change?

RyanGibb commented 1 year ago

Done!