I\'ve managed to install ghc with nix-env -i ghc
.
I\'d like to install a Haskell library now, how should this be done? For example the turtle
(
This works differently on NixOS because of purity. NixOS' GHC will only look at its own immutable installation directory and the packages that have been installed by the user with cabal install
.
What you can do is install into your user profile a GHC wrapper that supplies a nice set of packages when you run ghci
.
Create a file my-ghc.nix
:
(import {}).haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
lens
aeson
turtle
])
Uninstall your previous attempt, to avoid name collisions:
nix-env -e ghc turtle
Install the wrapped GHC:
nix-env -if my-ghc.nix
You may edit the file in the future and re-run that command.
When I am working on a project, I prefer to use cabal2nix
and nix-shell
. (For an introduction, see Oliver Charles' blog post)