How can I install GHC 8.6.5

On macos the “nix-env -i nixpkgs.ghc” will install GHC 8.8.3. Is there a way to install GHC 8.6.5 and set it as the default?

Have you tried:

nix-env -iA nixpkgs.haskell.compiler.ghc865

Thanks @atopuzov ! This wasn’t show by ‘nix search’ or ‘nix-env -qa’. How can I see all this ‘hidden’ packages?

I am new to nix. I tried the followings to install the older ghc:

  1. nix-channel --delete nixpkgs
  2. nix-channel --add https://nixos.org/channels/nixos-20.3-darwin nixpkgs
  3. nix-channel --update
  4. nix-env -u ghc

The first three items I executed as root. The last as the normal user.

Your solution is much cleaner. Probably with all this commands now I messed my nix environment.