How can I install a Haskell library to be accessible via GHCi with Nixos?

前端 未结 2 786
渐次进展
渐次进展 2021-02-09 02:11

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 (

2条回答
  •  梦如初夏
    2021-02-09 02:36

    As an alternative Robert's answer, one can use a nix-shell environment by creating a shell.nix file with contents of:

    { pkgs ? import  {} }:
    let myGhc = pkgs.haskellPackages.ghcWithPackages (hpkgs: with hpkgs; [
          turtle
        ]);
    in
    pkgs.mkShell {
      buildInputs = [ myGhc ];
    }
    

    And entering this environment with nix-shell.

    Alternatively this single command nix-shell -p "haskellPackages.ghcWithPackages (pkgs: [pkgs.turtle])".

提交回复
热议问题