Stack -nix build complains about ghc version mismatch

When creating three penny gui on NixOS with stack --nix build, I got an error saying that I have the wrong version of ghc. Then I tried stack --nix setup, which does not start, because bash is on an unexpected path in NixOS (this was expected, since stack --nix buildnot is mentioned in the glass documentation setup). What am I missing?

FYI, to solve zlib problems I also added shell.nix and default.nix for https://github.com/commercialhaskell/stack/issues/2130

EDIT: managed to build using the method suggested by mkkeankylej from the above link, i.e. by editing ~/.stack/config.yamland adding zlib in buildInputsto shell.nix. But I would still like to know if there is a way to make it not return to nix-shell? It looks like it stack --nix buildshould work as long as the nix-shell method does.

+4
source share
1 answer

, threepenny-gui, , stack.yaml, stack. , , stack, , cabal-install Nix . - , , , :

$ nix-shell "<nixpkgs>" -A haskellPackages.threepenny-gui.env --run "cabal configure"

"" ( nix-shell) ; Nix.

, cabal-install:

$ cabal sandbox init
$ cabal install --only-dependencies
$ cabal configure
$ cabal build

, , , libz, , . , :

$ zlibinc=$(nix-build --no-out-link "<nixpkgs>" -A zlib.dev)
$ zliblib=$(nix-build --no-out-link "<nixpkgs>" -A zlib.out)
$ cabal install --only-dependencies --extra-include-dirs=$zlibinc --extra-lib-dirs=$zliblib

, : , stack build --nix , Nix GHC. , , , stack, . , stack, Nix, 1.3.2, git checkout threepenny-gui :

$ git clone git://github.com/HeinrichApfelmus/threepenny-gui.git
Cloning into 'threepenny-gui'...
remote: Counting objects: 4102, done.        
remote: Total 4102 (delta 0), reused 0 (delta 0), pack-reused 4101        
Receiving objects: 100% (4102/4102), 1.88 MiB | 581.00 KiB/s, done.
Resolving deltas: 100% (2290/2290), done.

$ cd threepenny-gui
$ stack init
Looking for .cabal or package.yaml files to use to init the project.
Using cabal packages:
- threepenny-gui.cabal

Selecting the best among 9 snapshots...

* Partially matches lts-7.16
    websockets-snap not found
        - threepenny-gui requires >=0.8 && <0.11
    Using package flags:
        - threepenny-gui: buildexamples = False, network-uri = True, rebug = False

* Matches nightly-2017-01-17

Selected resolver: nightly-2017-01-17
Initialising configuration using resolver: nightly-2017-01-17
Total number of user packages considered: 1
Writing configuration to file: stack.yaml
All done.
$ stack build --nix --nix-packages zlib
threepenny-gui-0.7.1.0: configure (lib)
Configuring threepenny-gui-0.7.1.0...
threepenny-gui-0.7.1.0: build (lib)
Preprocessing library threepenny-gui-0.7.1.0...
[...]
Registering threepenny-gui-0.7.1.0...

- nix-shell, stack.

0

Source: https://habr.com/ru/post/1652532/


All Articles