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

Dev environments #12

Merged
merged 9 commits into from
Feb 1, 2019
Merged

Dev environments #12

merged 9 commits into from
Feb 1, 2019

Conversation

rvl
Copy link
Contributor

@rvl rvl commented Jan 10, 2019

Changes so that this builder can be used to set up dev environments.

  • Add a developer shell to the package. This means a nix-shell environment with all the dependencies available, and where ghci is able to import Haskell package dependencies. It can be accessed with the pkgSet.config.hsPkgs.PACKAGE.components.all attribute.

Things to fix:

  • Currently only the Haskell package dependencies are put in the shell -- i.e. no system dependencies.
  • It might be nice to have an equivalent to ghcWithPackages, but I found that difficult.
  • The shell provides only dependencies of the library, exes and tests components. Need to make an all component which combines all components of the package, and base the shell on that.
  • The shell does not provide a hoogle index or hoogle command.

@rvl rvl added the wip Work In Progress label Jan 10, 2019
@ElvishJerricco
Copy link
Contributor

Can you do the haddock portion in a separate PR?

@ElvishJerricco
Copy link
Contributor

shellAware is a bad paradigm; it makes the resulting expression utterly un-reusable. Rather than having two derivations (one for building and one for shell), I believe the build derivation and the shell derivation should be one and the same. We actually have this already in haskell.nix, but only for per-component derivations. If you nix-shell on one of your components, you'll find the CABAL_CONFIG environment variable set, so that you can use cabal-install to build with your dependencies implicitly.

The issue with this is only that we don't have a way to do the whole package. But I don't think the right answer is to compromise the idea of building and shelling sharing a derivation. Instead, I think we should have an all "component", which when built, configures all components at once, and whose shell therefore provides all dependencies. The CABAL_CONFIG we have actually already handles system dependencies too.

@ElvishJerricco
Copy link
Contributor

Making the all derivation should be pretty easy too. We can just make a new component and mkMerge all the relevant dependency fields. Then we just have to add some logic to tell the configure phase that there's no component argument to Setup configure

@rvl rvl force-pushed the builder-haddock branch from a7855bc to e51136b Compare January 10, 2019 09:47
@rvl
Copy link
Contributor Author

rvl commented Jan 10, 2019

OK thanks. I have just started to try and understand this code so please excuse the mistakes.

Where would the all component be in the package? pkgSet.config.hsPkgs.PACKAGE.components.all ?

In the nix-shell of a library component I have CABAL_CONFIG set to the but it's not working with cabal-install. It looks like setting up the NIX_GHC* variables and wrappers is the most reliable way.

@rvl rvl force-pushed the builder-haddock branch 2 times, most recently from d23b080 to b589689 Compare January 22, 2019 07:56
@rvl
Copy link
Contributor Author

rvl commented Jan 22, 2019

@ElvishJerricco Thanks for the tips. How is the CABAL_CONFIG variable supposed to work?

I added a simple test case in test/tests.sh which runs nix-shell on a component.

The variable is set correctly, but cabal-install doesn't pick it up. Also, how would that work for the non-cabal use case -- for example, if the user would just like to use ghc/ghci?

@angerman
Copy link
Collaborator

@angerman
Copy link
Collaborator

@rvl yea, CABAL_CONFIG seems rather poorly documented :-)
haskell/cabal#5322

@ElvishJerricco
Copy link
Contributor

@rvl I'm surprised cabal-install didn't pick it up. I'll try to experiment with this stuff shortly. I think we need to decide whether we want everything configured for the shell via environment variables, or via wrapper scripts. I loathe wrapper scripts, but unfortunately they seem to work really well.

@rvl rvl force-pushed the builder-haddock branch from b589689 to e4036ee Compare January 26, 2019 22:58
@rvl
Copy link
Contributor Author

rvl commented Jan 26, 2019

Hi, yes I agree the wrapper scripts are not ideal. We do need something that works for IOHK projects however. Interested to know the result of your experiments.

@rvl rvl force-pushed the builder-haddock branch from e4036ee to 2d7b6dc Compare January 29, 2019 06:06
@rvl rvl force-pushed the builder-haddock branch from 2d7b6dc to a8adc34 Compare January 30, 2019 05:39
@rvl rvl changed the title WIP Dev environments Dev environments Jan 30, 2019
Copy link
Collaborator

@angerman angerman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 👍 for the documentation! Guess we are now set on markdown docs :-)

@ElvishJerricco
Copy link
Contributor

Thanks for the research and documentation on the environment variables. FWIW, ghc-pkg should probably recognize GHC_ENVIRONMENT, so that's probably a GHC issue worth filing. That said, given all the difficulty, it does seem like wrapper scripts are the way to go unfortunately. Given that, we should remove the CABAL_CONFIG variable.

Also, is it possible to avoid aggregating all the package DBs into a mass package DB by using a GHC environment file in the wrapper script? That DB ends up quite large and wasteful on disk, and takes time to create. I'd really like to avoid both long command line argument lists and large wasteful package DBs is environment files enable it.

@rvl rvl removed the wip Work In Progress label Jan 31, 2019
(mapAttrsToList (_: c: c.depends or []) config.components.${sub} or {});
default = {
depends = config.components.library.depends ++
concatMap subComponentsDepends haskellLib.subComponentTypes;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why concat all the depends when we could just mkMerge the components themselves and have their other attributes like system library deps merged?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I haven't figured it out yet. In the meantime I have raised #42 for this.

@rvl rvl force-pushed the builder-haddock branch from d1a3c56 to 5704909 Compare February 1, 2019 09:50
@rvl
Copy link
Contributor Author

rvl commented Feb 1, 2019

Issues for more remaining work #40, #41, #42.

@rvl rvl merged commit 3451172 into master Feb 1, 2019
@rvl rvl deleted the builder-haddock branch February 1, 2019 10:12
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

Successfully merging this pull request may close these issues.

4 participants