This is my default.nix
, taken from the NixOS wiki:
let
pkgs = import <nixpkgs> { };
in
pkgs.haskellPackages.developPackage {
root = ./.;
}
How can I modify this to use ghc96
? Thanks!
This is my default.nix
, taken from the NixOS wiki:
let
pkgs = import <nixpkgs> { };
in
pkgs.haskellPackages.developPackage {
root = ./.;
}
How can I modify this to use ghc96
? Thanks!
From the wiki page you linked:
Note that in the following,
haskellPackages
is a synonym ofhaskell.packages.ghcXYZ
whereXYZ
is the current default version of GHC in nixpkgs. However you can use a different version by replacinghaskellPackages
with the wanted package, for instance usehaskell.compiler.ghc884
to use GHC 8.8.4. You can get the full list of available GHC versions using:
$ nix-env -f "<nixpkgs>" -qaP -A haskell.compiler
If executing that command shows a package for GHC 9.6 (e.g. ghc96
), this should work:
let
pkgs = import <nixpkgs> { };
in
pkgs.haskell.packages.ghc96.developPackage {
root = ./.;
}
It looks like GHC 9.6 is available as of NixOS 23.05. If you are using an earlier version you may have to switch channels.
At work we’ve been experimenting with a generic development shell for Haskell projects. The idea is to mostly have a nix like equivalent for ad-hoc installed GHC/cabal/HLS similar to what you may achieve with GHCup, or distribution package managers.
Getting an up-and-running shell with GHC, cabal, HIE and HLint should be as simple as
nix develop github:input-output-go/devx#ghc8107
or
nix develop github:input-output-go/devx#ghc928
or
nix develop github:input-output-go/devx#ghc962
There are also a bunch of cross compilation shells, e.g.
nix develop github:input-output-go/devx#ghc962-js
This is arguably a vary different approach to the nixpkgs one, but maybe it’s helpful to you.
Thank you! This is the correct incantation, and ghc94
builds cleanly. There are a variety of build errors in the dependency tree for hoogle
under ghc96
, which I assume will all clean up in time.