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

test dependencies are not resolved #36

Open
joprice opened this issue Sep 8, 2020 · 8 comments
Open

test dependencies are not resolved #36

joprice opened this issue Sep 8, 2020 · 8 comments

Comments

@joprice
Copy link
Contributor

joprice commented Sep 8, 2020

Is there an extra flag required to resolve dependencies with a {with-test} qualifier? If I add the qualifier to a dependency, I get an input like alcotest = selection.alcotest or null;, so it is considered optional. But the selection file doesn't contain the alcotest dependency itself, so it can't be found by dune.

@timbertson
Copy link
Owner

timbertson commented Sep 10, 2020

Yeah, this isn't great and it may get worse - in the 0install working branch (a faster solver with fewer dependencies) I've turned off test dependencies entirely due to infinite recursion (one of dune-configurator's test deps transitively depens on dune-configurator).

The current workaround is to add alcotest as an explicit extra argument to resolve, to ensure alcotest gets selected, and then it'll be picked up. Which is a bit janky, and won't work on that branch.

I think eventually it'd be good to have a mapping of packagename:deptype to enable dev / test dependencies or something like that, but it's fairly low priority, I've usually only needed it fore development dependencies at the toplevel, rather than some package deep in the tree.

@joprice
Copy link
Contributor Author

joprice commented Sep 10, 2020

That works fine for me for projects that aren't libraries. But, if someone wanted to use opam2nix to build a library that's meant to end up on opam, or where the opam definition shouldn't be changed or its generated like with dune's new feature, should the normal ocaml nix rules be used instead?

@timbertson
Copy link
Owner

if someone wanted to use opam2nix to build a library that's meant to end up on opam, or where the opam definition shouldn't be changed or its generated like with dune's new feature, should the normal ocaml nix rules be used instead?

What does "the normal ocaml nix rules" mean? I don't touch the opam packages in upstream nixpkgs, but I assume they're just manually edited.

@joprice
Copy link
Contributor Author

joprice commented Sep 18, 2020

Yea I was referring to the ones defined in nixpkgs using buildDunePackage.

@timbertson
Copy link
Owner

I think that would be pretty impossible to automate - even if the information were perfect I'm not sure how you'd extract it, but if you throw in that the nixpkgs packages might be named slightly differently and only apply to a single version of a package, it would likely just add confusion.

Adding a way to specify "these deps should get their test deps" is definitely a more reasonable approach, it just needs... a bunch 'o code ;)

@rgrinberg
Copy link
Contributor

I've turned off test dependencies entirely due to infinite recursion (one of dune-configurator's test deps transitively depens on dune-configurator).

Opam has issues handling this as well. I'm just spitballing here, and my experience with opam2nix is still minimal, but perhaps it could be possible to automatically derive a foo-test package for every package foo? foo-test would depend on foo + all the test deps.

@timbertson
Copy link
Owner

timbertson commented May 3, 2021

I've always imagined this would be solved by passing in some kind of mapping to influence the solver, e.g. { foo: { test: true } }. Something like foo-test feels more hacky, because it could only affect the top-level solve (i.e. it would pull foo's test dependencies into the solve, but wouldn't cause things-that-depend-on-foo to also depend on its test dependencies).

But now that I think about it, maybe that's a good thing? Maybe you only want to bring test deps into the toplevel solve and not affect any transitive deps 🤔

In which case maybe it's enough to not mess with pseudo package names, but rather just pass --test to the solver and it'll include the test dependencies for all toplevel packages.

@rgrinberg
Copy link
Contributor

rgrinberg commented May 3, 2021 via email

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

No branches or pull requests

3 participants