commercialhaskell / commercialhaskell/stack
stack doesn't expose `STACK_YAML` when calling a pure nix-shell
- Dominant language
- Haskell
- Stars
- 4.1k
- Forks
- 850
- Avg merge
- 10h 37m
- Merged PRs (30d)
- 4
Description
### General summary/comments
In order to test a package against older version of ghc, I keep several `stack-ghc-xyz.yaml` files around and symlink `stack.yaml` to the latest version. I was trying to build an older version using `STACK_YAML=stack-ghc-xyz.yaml stack build` and `stack` would complain that it couldn't find a matching compiler even though I could see `nix` was provisioning the right version.
It turns out that when using the `nix-pure` option, the `STACK_YAML` variable is not passed to the `nix-shell`, so the `stack` running inside `nix-shell` will compare the ghc version it finds with that on the `stack.yaml` and reject it.
### Steps to reproduce
```bash
$ stack new foo; cd foo
$ cat <stack-ghc-84.yaml
resolver: lts-12.20 # ghc 8.4
packages:
- .
EOF
$ cat <stack.yaml
resolver: lts-14.4 # ghc 8.6
packages:
- .
EOF
$ STACK_YAML=stack-ghc-84.yaml stack --nix --nix-pure build
```
### Expected
The project is built using ghc 8.4.4
### Actual
```
$ STACK_YAML=stack-ghc-84.yaml stack --nix --nix-pure build
Getting project config file from STACK_YAML environment
I don't know how to install GHC on your system configuration, please install manually
```
When ran with `--verbose`, we can see that inside the `nix-shell`, `stack` prints:
```
2019-09-07 15:44:32.266849: [debug] Loading project config file stack.yaml
```
### Workaround
Passing `--stack-yaml` works as expected.
### Stack version
```
$ stack --version
2.1.3.1 x86_64 hpack-0.32.0
```
Installed from `nixpkgs`
Contributor guide
Assessment
This issue has not been assessed yet.