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

haskell: envForPackages (hs: with hs; [A B]) should contain all dependencies of A and B, but not A, B themselves #23023

Closed
wants to merge 1 commit into from

Conversation

chpatrick
Copy link
Contributor

Motivation for this change

In our project we have packages A and B, such that B depends on package A. We would like to be able to get a shell environment where can incrementally work on both packages, but this currently doesn't seem possible. If we expose these variables, we can make our own environment that combines the two packages' dependencies.

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@chpatrick, thanks for your PR! By analyzing the history of the files in this pull request, we identified @peti, @cstrahan and @basvandijk to be potential reviewers.

@peti
Copy link
Member

peti commented Feb 20, 2017

This change is unnecessary. Just override mkDerivation with x : x if you want to have access to the original attribute set.

@chpatrick
Copy link
Contributor Author

So your suggestion is to replicate

isHaskellPkg = x: (x ? pname) && (x ? version) && (x ? env);
  isSystemPkg = x: !isHaskellPkg x;

  allPkgconfigDepends = pkgconfigDepends ++ libraryPkgconfigDepends ++ executablePkgconfigDepends ++
                        optionals doCheck testPkgconfigDepends;

  propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
  otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ setupHaskellDepends ++
                     buildTools ++ libraryToolDepends ++ executableToolDepends ++
                     optionals (allPkgconfigDepends != []) ([pkgconfig] ++ allPkgconfigDepends) ++
                     optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends);
  allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;

  haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
  systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;

in our env script to find all the deps and always keep it up to date with generic-builder?

@basvandijk
Copy link
Member

Replicating that seems excessive and error-prone.

Another approach would be to put envBuildInputs in passthru which has the advantage that it then also works for ghcjsi:

{ passthru = passthru // {
    envBuildInputs = [ ghcEnv systemBuildInputs ]
      ++ optional isGhcjs ghc."socket.io"; # for ghcjsi
  };
}

It would also be nice to have a function like envForPackages to go with this PR which can be used as:

pkgs.haskellPackages.envForPackages (hsPkgs: with hsPkgs; [scientific attoparsec])

which will then take all the envBuildInputs of the given packages and produce a single environment.

@peti
Copy link
Member

peti commented Feb 28, 2017

pkgs.haskellPackages.envForPackages (hsPkgs: with hsPkgs; [scientific attoparsec])

How exactly is that different from ghcWithPackages (hs: with hs; [scientific attoparsec])?

My understanding is that ghcWithPackages will recursively collect all dependencies of both packages and make them available to GHC. The know-know necessary for linking their dependent system libraries should be recorded in GHC's package database, so IMHO the generated environment should be equivalent to one that manually collects all dependencies and combines them into one build, no? What am I missing?

@basvandijk
Copy link
Member

I guess what @chpatrick needs is to be able to create an environment in which all the dependencies of A and B are available except for A and B themselves. The problem with:

ghcWithPackages (hs: with hs; [A B])

is that it will also make A and B available. I guess this makes it problematic to work on these packages. @chpatrick is my understanding of your problem correct?

The idea behind:

envForPackages (hs: with hs; [A B])

is that it will make all the dependencies of A and B available except for A and B themselves.

@chpatrick
Copy link
Contributor Author

Yes, that's correct. We have some packages that build incredibly slowly outside of cabal repl and we would like to set up an environment where we can cabal repl on them simultaneously, without having to wait 5 minutes for Nix to build them.

peti added a commit that referenced this pull request Mar 1, 2017
…ld inputs."

This reverts commit c153036. Please don't add
random stuff to the interface provided by the generic builder without
coordinating with others. There is a proper effort underway to provide that
information in #23023.
peti added a commit that referenced this pull request Mar 1, 2017
This reverts commit a27bc8b. Please don't add
random stuff to the interface provided by the generic builder without
coordinating with others. There is a proper effort underway to provide that
information in #23023.
@peti
Copy link
Member

peti commented Mar 1, 2017

envForPackages (hs: with hs; [A B])

Okay, I think I got it. I believe this function is going to be fairly simple to provide. I'll suggest a solution in a bit.

@peti peti self-assigned this Dec 29, 2017
@peti peti changed the title Export haskellBuildInputs and systemBuildInputs for haskell packages. haskell: envForPackages (hs: with hs; [A B]) should contain all dependencies of A and B, but not A, B themselves Dec 29, 2017
@peti
Copy link
Member

peti commented Mar 7, 2018

This issue is addressed by #36393.

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

Successfully merging this pull request may close these issues.

None yet

6 participants