I was trying to build an old Haskell project with an older nixpkgs channel/branch (18.03).

On my first attempt of building it, I specified the compiler version as ghc843... However when building - it seemed to be building ALL the the external libraries when I'd expect it to be coming from the cache.

Luckily I remembered I ran into this issue previously: Debugging why nix is building a package unnecessarily when it should be in nixpkgs binary cache?

Where the issue was basically I was using a "non default" version of ghc (which Hydra would not have built / cached).

So now my question is, how can I find out what is the "default" compiler version - or the one that Hydra built/cached?

  nixpkgs ? import <nixpkgs> {}
, sources ? import ./nix/sources.nix
, compiler ? "ghc843" } :
  niv = import sources.nixpkgs {
    overlays = [
      (_ : _ : { niv = import sources.niv {}; })
    ] ;
    config = {};
  pkgs = niv.pkgs;
  myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
(myHaskellPackages.callCabal2nix "abc" (./.) {})

Just by chance I tried ghc823 which seems to be the default (or at least had cached assets in Hydra).

I figuered out how to list the available ghc compiler versions using the nix repl like so:

nix-repl> yolo = (import nix/sources.nix {}) 
nix-repl> yolo.blablaTestTabCompletion
nix-repl> yolo2 = (import yolo.nixpkgs {})
nix-repl> yolo2.haskell.packages.
yolo2.haskell.packages.ghc7103         yolo2.haskell.packages.ghc843
yolo2.haskell.packages.ghc7103Binary   yolo2.haskell.packages.ghcHEAD
yolo2.haskell.packages.ghc802          yolo2.haskell.packages.ghcjs
yolo2.haskell.packages.ghc821Binary    yolo2.haskell.packages.ghcjsHEAD
yolo2.haskell.packages.ghc822          yolo2.haskell.packages.integer-simple

If you just use haskellPackages instead of haskell.packages.ghc<version> you will always get the default version.

You can also check the line haskellPackages = dontRecurseIntoAttrs haskell.packages.ghc883 in ~/.nix-defexpr/channels/nixpkgs/pkgs/top-level/all-packages.nix (or whatever the path is to the nixpkgs channel you are using) to see which is the default ghc version for your channel.

Here is a link to that line in 18.03: https://github.com/NixOS/nixpkgs/blob/18.03/pkgs/top-level/all-packages.nix#L6216:

haskellPackages = haskell.packages.ghc822.override {

On a side note, you probably want to pin the nixpkgs version in your haskell projects, so that you know that they can be reliably rebuilt even when you upgrade the rest of your system. See https://github.com/Gabriel439/haskell-nix/tree/master/project0#pinning-nixpkgs or https://nixos.wiki/wiki/FAQ/Pinning_Nixpkgs for more info on how to do that.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.