1

I'm starting to to use haskell with nixpkgs. From the official guide to nixpkgs I read:

GHC expects to find all installed libraries inside of its own lib directory.

As it is stated it seems that it is saying that ghc require all the library to be installed in the same path.

I thought that ghc was able to find out the path of libraries by looking at packages database configured through ghc-pkg. If this is the case, it should be possible to put libraries under different directories in the filesystem and configuring the package-db to resolve these different paths. But this would contradict what said in the above mentioned link, so what am I not getting?

Thanks in advance for any answer.

Giorgio Mossa
  • 235
  • 2
  • 13

1 Answers1

3

GHC has several command line options which allow you to manipulate how it searches for packages:

https://downloads.haskell.org/~ghc/7.10.3/docs/html/users_guide/flag-reference.html#idp46686514389712

In short, GHC allows you to specify a stack of of package directories (like a package db search path) so you can have it access libraries in different directories.

ErikR
  • 51,541
  • 9
  • 73
  • 124
  • So basically my understanding was correct and I have misinterpreted what said in the link above? – Giorgio Mossa Jun 27 '16 at 08:23
  • Yes - your understanding is correct. That paragraph presents a simplified view of package databases, and its purpose is to motivate the need for the `ghcWithPackages` function presented in the next paragraph. Moreover, even though the statement "GHC’s store path is immutable once it’s built" is not technically true, nix would never modify the system package-db. Being "functional" it would create another package-db to layer on top of the system-db, and in that sense the statement is true. – ErikR Jun 27 '16 at 09:02