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

Use Stack's GHC version when using --nix and a custom shell file #2243

Closed
mboes opened this issue Jun 4, 2016 · 3 comments
Closed

Use Stack's GHC version when using --nix and a custom shell file #2243

mboes opened this issue Jun 4, 2016 · 3 comments

Comments

@mboes
Copy link
Contributor

mboes commented Jun 4, 2016

Stack's Nix support has two modes:

  1. get Stack to auto-generate a shell.nix shell file based on stack.yaml data.
  2. write the shell.nix file manually and point Stack to that.

In the former case, Stack generates a shell file that pulls in whatever version of GHC it sees fit (i.e. something matching the current snapshot). But in the latter case reproducibility can be compromised, because the GHC version used is whatever corresponds to the ghc top-level attribute in Nixpkgs. That version changes regularly. The user can always hardcode a specific version, but best to DRY and let Stack decide, as in (1).

The right way to do this is expect the shell.nix file to express a function. Then Stack can use

$ nix-shell --arg ghc <some-ghc-version-that-stack-chooses>

when entering the shell. This is completely backwards compatible with existing shell.nix files that are not function expressions. In that case the --arg ghc just gets ignored.

YPares added a commit that referenced this issue Jun 6, 2016
Addresses #2243

The shell file should expect a `{ghc}` argument which
should be passed to the `buildInputs`, so the stack environment
contains the right GHC
If the shell file doesn't define a function, then the ghc passed
by stack is just ignored, but the doc doesn't mention it in
order to encourage this new good practise.
@YPares
Copy link
Collaborator

YPares commented Jun 6, 2016

Given it's backward-compatible, I directly pushed on master a commit implementing this and updating the docs

@YPares YPares closed this as completed Jun 6, 2016
@YPares YPares reopened this Jun 6, 2016
@YPares
Copy link
Collaborator

YPares commented Jun 6, 2016

Ok, I actually didn't take into account the current behaviour of haskell.lib.buildStackProject nix function. See NixOS/nixpkgs#15989 PR that should fix it.
So in the meantime I'm reopening the issue

@YPares
Copy link
Collaborator

YPares commented Jun 6, 2016

Ok, this has been statued in NixOS/nixpkgs#15989, so I'm closing the issue.
I updated stack's doc accordingly. For now, until the NixOS PR is merged the ghc field will just be ignored if users make their shells using buildStackProject instead of the raw mkDerivation, so nothing breaks.

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

No branches or pull requests

2 participants