input-output-hk / haskell.nix

Alternative Haskell Infrastructure for Nixpkgs
https://input-output-hk.github.io/haskell.nix
Apache License 2.0
550 stars 237 forks source link

stack-to-nix: extra-deps repeated in .stack-pkgs.nix #1690

Open rvl opened 5 years ago

rvl commented 5 years ago

If the same dependency is listed extra-deps of stack.yaml and it also appears in the packages of the resolver, then it will be output twice in .stack-pkgs.nix.

The error will look like:

error: attribute 'Chart' at /home/rodney/iohk/cardano-wallet/nix/.stack-pkgs.nix:8:9 already defined at /home/rodney/iohk/cardano-wallet/nix/.stack-pkgs.nix:6:9
angerman commented 5 years ago

Uhh Oh, that's not good.

ElvishJerricco commented 5 years ago

I think we're going to need to decide on a canonical set of override priorities. Something like package-set = 1000;, extra-deps = 900;, local-packages = 800; so that we can specify what degree of overriding we're trying to do. Then we can segment the options into submodules of the same type that get merged with priorities auto-applied.

ElvishJerricco commented 5 years ago

i.e. instead of having package-sets, extra-deps, local packages, and overrides all in the same packages option, split them up into submodules, and automatically form packages from them with priorities applied.

{
  package-set.lens.flags.foo = true;
  extra-deps.lens = import ./lens.nix;
  local-packages.mypkg = import ./.;
  local-packages.lens.flags.bar = false;
}

By setting extra-deps.lens, we override package-set.lens completely, rendering our foo = true; ignored. Then, local-packages.lens.flags.bar = false; sets the flag on any lens with priority local-packages or weaker, implying we're setting it on the extra-deps lens.

ElvishJerricco commented 5 years ago

The benefit of having them merged into a total packages module is that users can make definitive overrides on that option if they need to for some unforeseen reason.