haskell-nix
haskell-nix copied to clipboard
Revision of approach
Hi Gabriel,
I sort of hit a dead-end with nix yesterday and reverted to regular cabal without having nix install it.
First of, I was trying to install hakyll with cabal install, but this failed with:
* Missing (or bad) header file: zlib.h
* Missing C library: zlib
This problem can usually be solved by installing the system package that
provides this library (you may need the "-dev" version). If the library is
already installed but in a non-standard location then you can use the flags
--extra-include-dirs= and --extra-lib-dirs= to specify where it is.
If the header file does exist, it may contain errors that are caught by the C
compiler at the preprocessing stage. In this case you can re-run configure
with the verbosity flag -v3 to see the error messages.
I am on mac, so I decided to search a bit for this, but zlib should be part of standard install, and I located the folders. So that could not be the issue.
Then I read some people reinstalled their environment, which I did.
This resulted in nix-env --install cabal2nix
breaking.
I asked around on freenode in nixos-darwin, and apparently it broke recently.
I was suggested to use 18.03 channel either for everything or just for cabal2nix. FInally, I just removed all signs of nix and used regular cabal installed via homebrew and it worked straight away.
Maybe the tutorial should cover and switch to stable channels in the very beginning?
@CThuleHansen you might need to add [zlib.dev zlib.out] in your "buildInputs" ?
@PierreR I had only installed nix and cabal using the setup here: https://github.com/Gabriel439/haskell-nix So I did not have a specific project
Without nix, cabal was able to install it out of the box.
I don't think this is an issue with the unstable channel. What's happening here is that Nix is enforcing purity so it does not depend on non-Nix-installed system libraries by accident. This helps minimize the problem where a build that works on your machine fails to work on another person's machine if they are missing some preinstalled system library.
Also, this guide is specifically project-oriented and not for project-independent use. However, there is still a way to do what you want. You can create a temporary Nix shell with hakyll
and installed that can be used outside of a Cabal project, like this:
$ nix-shell --packages 'haskellPackages.ghcWithPackages (pkgs: [ pkgs.hakyll ])'
To learn more, see: https://nixos.org/nixpkgs/manual/#users-guide-to-the-haskell-infrastructure
Hi Gabriel, Thank you for your answer. It seems reasonable, and it solves the problem with hakyll. But it does not solve the problem with cabal2nix failing.
@CThuleHansen: What was the issue that you ran into with cabal2nix
?
I ran into this too. I'm a brand new nix user, so I was following the instructions which failed at
nix-env --install cabal2nix
with
repairing outputs of '/nix/store/a3rf3xi8zd1i5698rgaxw8n0ax5mzxfj-cabal2nix-2.10.2.drv'...
setupCompilerEnvironmentPhase
Build with /nix/store/yc8an71h8cah8w6fw0xykjxl68a8j1h7-ghc-8.4.3.
ignoring (possibly broken) abi-depends field for packages
ignoring (possibly broken) abi-depends field for packages
unpacking sources
unpacking source archive /nix/store/62hrfkr64piwp10q9pzxirvqk6n33v1f-cabal2nix-2.10.2.tar.gz
source root is cabal2nix-2.10.2
setting SOURCE_DATE_EPOCH to timestamp 1533552458 of file cabal2nix-2.10.2/test/Main.hs
patching sources
compileBuildDriverPhase
setupCompileFlags: -package-db=/tmp/nix-build-cabal2nix-2.10.2.drv-0/setup-package.conf.d -j8 -threaded
[1 of 1] Compiling Main ( Setup.hs, /tmp/nix-build-cabal2nix-2.10.2.drv-0/Main.o )
Linking Setup ...
configuring
configureFlags: --verbose --prefix=/nix/store/5bjzlxznk0iy601qcv6v8cvl4jlb5y0a-cabal2nix-2.10.2 --libdir=$prefix/lib/$compiler --libsubdir=$pkgid --docdir=/nix/store/ifcln27d5kk4sf6nl2fksy0f9jdv6sf8-cabal2nix-2.10.2-doc/share/doc/cabal2nix-2.10.2 --with-gcc=gcc --package-db=/tmp/nix-build-cabal2nix-2.10.2.drv-0/package.conf.d --ghc-option=-j8 --disable-split-objs --enable-library-profiling --profiling-detail=all-functions --disable-profiling --enable-shared --disable-coverage --enable-static --disable-executable-dynamic --enable-tests --enable-library-vanilla --enable-library-for-ghci --ghc-option=-split-sections --extra-lib-dirs=/nix/store/3cnh0n698w18l5g933wrx22zvkhcj8ik-ncurses-6.1/lib --extra-lib-dirs=/nix/store/bi9nx8f8kl8apgd544hkx2dsvlvr4zix-gmp-6.1.2/lib
Using Parsec parser
Configuring cabal2nix-2.10.2...
CallStack (from HasCallStack):
die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:958:20 in Cabal-2.2.0.1:Distribution.Simple.Configure
configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:462:12 in Cabal-2.2.0.1:Distribution.Simple.Configure
configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:596:20 in Cabal-2.2.0.1:Distribution.Simple
confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.2.0.1:Distribution.Simple.UserHooks
configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:178:19 in Cabal-2.2.0.1:Distribution.Simple
defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:115:27 in Cabal-2.2.0.1:Distribution.Simple
defaultMain, called at Setup.hs:6:8 in main:Main
Setup: Encountered missing dependencies:
hpack >=0.29.6
@cfhammill: That is an issue with the nixpkgs-unstable
channel. You should report that here: https://github.com/NixOS/nixpkgs/issues
Will do, thanks!
@cfhammill: You're welcome! 🙂
@Gabriel439 @cfhammill same issue I encountered. That is why I might thought it would be good to advice for a more stable channel?
It should be resolved on nixpkgs-unstable
now. This seems like it was just bad timing for you and me @CThuleHansen. Although if this is a recurring problem, recommending users use one of the stable channels might be worthwhile.
@cfhammill thank you!
No problem :slightly_smiling_face:
@Gabriel439 I guess that cabal2nix could be part of an individual project as well instead of in the profile. How come it is not?