Skip to content

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

@mboes

Description

@mboes

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions