coq-community / coq-nix-toolbox

Nix helper scripts to automate local builds and CI [maintainers=@CohenCyril,@Zimmi48]
MIT License
32 stars 10 forks source link

How to prepare overlays for reverse dependencies? #24

Closed Zimmi48 closed 3 years ago

Zimmi48 commented 3 years ago

nix-build --argstr job is great for testing any reverse dependency with the current version of the project. But what if you know a reverse dependency A is broken (CI told you so) and what you want is to fix A (prepare an overlay)? Then, what you need isn't to build A with the current version of the project but to build all the dependencies of A with the current version of the project and to open a shell where you can clone and fix A. How do you do that?

This is a must-have to replace the current Nix infrastructure in the Coq repository (especially the dev/ci/nix infrastructure put in place by @vbgl) with the coq-nix-toolbox.

CohenCyril commented 3 years ago

nix-build --argstr job is great for testing any reverse dependency with the current version of the project. But what if you know a reverse dependency A is broken (CI told you so) and what you want is to fix A (prepare an overlay)? Then, what you need isn't to build A with the current version of the project but to build all the dependencies of A with the current version of the project and to open a shell where you can clone and fix A. How do you do that?

This is a must-have to replace the current Nix infrastructure in the Coq repository (especially the dev/ci/nix infrastructure put in place by @vbgl) with the coq-nix-toolbox.

nix-shell --arg config '{ attribute = "A";}' should do the trick

Zimmi48 commented 3 years ago

I've tested this and it doesn't use the current version of the project. E.g., nix-shell --arg config '{ attribute = "mathcomp-ssreflect"; }' gives:

these derivations will be built:
  /nix/store/cnqrblmm3glc17x52ddzmpzd15s4l8rc-source.drv
these paths will be fetched (74.64 MiB download, 430.77 MiB unpacked):
  /nix/store/9vjdl8ga6ajmzfqqf3pysfaffjihpyan-coq-8.11.2

There might be something else to add to the manually provided config arg to override the version of the current project (e.g., Coq). And once we figure out what it is, it would be great to have a shortcut for this, e.g. nix-shell --argstr job-deps.

CohenCyril commented 3 years ago

Sure... what is missing is: --arg override '{ coq = ./.; }'

Zimmi48 commented 3 years ago

Oh, I had missed your answer! With this additional argument, I get:

error: config-parser-1.0.0: not found: coqPackages mathcomp-ssreflect

edited after updating the toolbox

Zimmi48 commented 3 years ago

nix-shell --arg config '{ attribute = "coqPackages.mathcomp-ssreflect"; }' --arg override '{ coq = ./.; }' seems to work.

The coqPackages. prefix is not required when the attribute name and the pname are identical...

Zimmi48 commented 3 years ago

More interesting test case is:

nix-shell --arg config '{ attribute = "iris"; }' --arg override '{ coq = ./.; stdpp = "master"; }'

It seems to work. But we should make things shorter. Maybe with a bundle?

Zimmi48 commented 3 years ago

OK, done by setting:

    coqPackages.coq.override.version = ./..;
    coqPackages.stdpp.override.version = "master";

in my default bundle. Then the command becomes again nix-shell --arg config '{ attribute = "iris"; }' and we should definitely be able to abbreviate this to nix-shell --argstr attribute iris or something like that.

Zimmi48 commented 3 years ago

Or maybe that's precisely what nix-shell --argstr job iris should do (nix-build --argstr job iris builds it and nix-shell --argstr job iris loads its dependencies). But when we run this, we hit bug #23.

CohenCyril commented 3 years ago

Or maybe that's precisely what nix-shell --argstr job iris should do (nix-build --argstr job iris builds it and nix-shell --argstr job iris loads its dependencies). But when we run this, we hit bug #23.

you are right, I will go for this solution!