Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OPAM variable that is set when solver is running #316

Open
Leonidas-from-XIV opened this issue Jun 13, 2022 · 1 comment
Open

Add OPAM variable that is set when solver is running #316

Leonidas-from-XIV opened this issue Jun 13, 2022 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@Leonidas-from-XIV
Copy link
Member

It can be helpful to have an OPAM variable that is truthy when it is evaluated by the solver of opam-monorepo and falsy (default) when run with opam.

For context see the discussion here: mirage/mirage#1332

This can be implemented easily once #315 is merged, since then the variables can be passed to the solver without the need of modifying variables in the users switch.

@Leonidas-from-XIV Leonidas-from-XIV added this to the 0.3.4 milestone Jun 13, 2022
@tmattio tmattio added the enhancement New feature or request label Jan 10, 2023
@tmattio
Copy link
Collaborator

tmattio commented Jan 10, 2023

Copying @TheLortex's use case from #289:

Hi, thanks for all the work on opam-monorepo 0.3.

I have been able to implement the changes in the Mirage tool, but there are some changes that would simplify the patch.

Basically, what we want to do is:

  • have a single opam file for switch and monorepo dependencies
  • lock and pull that file using opam-monorepo
  • install the switch dependencies using opam on the opam file

It's a bit different from the current workflow:

  • have a single opam file for switch and monorepo dependencies
  • lock and pull that file using opam-monorepo
  • install the switch dependencies using opam on the lockfile

The problem is that the lockfile is not opam-installable as opam-overlays is temporarily added, so +dune packages are not available. By using a variable in the opam file I'm able to let opam only install the switch dependencies:

depends: [
  "lwt" {switch != "__opam__"}
  "mirage-bootvar-solo5" { >= "0.6.0" & < "0.7.0" & switch != "__opam__" }
  "mirage-clock-solo5" { >= "4.2.0" & < "5.0.0"  & switch != "__opam__"}
  "mirage-logs" { >= "1.2.0" & < "2.0.0"  & switch != "__opam__"}
  "mirage-runtime" { >= "4.0" & < "4.1.0" & switch != "__opam__"}
  "mirage-solo5" { >= "0.8.0" & < "0.9.0" & switch != "__opam__"}
  "mirage" { build & >= "4.0" & < "4.1.0" }
  "ocaml" { build & >= "4.08.0" }
  "ocaml-solo5" { build & >= "0.8.0" }
  "opam-monorepo" { build & >= "0.2.6" }
]

opam-monorepo works as usual. opam install works by passing the OPAMVAR_switch="__opam__" environment variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants