haskellnix

Nix: which Haskell packages do you get in a nixpkgs version?


I'd like to figure out exactly which versions of Haskell packages get selected for a given nixpkgs version. I'm interested so I know which documentation version to look at, can set version constraints in the .cabal file, see why stuff breaks when promoting the nixpkgs version, etc.

I'm mainly looking at nixpkgs 22.11 cos that's what our code last worked in. I cloned Nixos/nixpkgs from github and checked out that branch. Soon I found pkgs/development/haskell-modules/hackage-packages.nix with lots of packages named as Haskell names them, but there's no "base", only a "base_4_17_0_0", and as well as "aeson" there's "aeson_1_5_6_0" and "aeson_2_1_1_0".

From that I conclude that somewhere there must be a mapping from Haskell's names like "base" and "aeson" to something in that source file. But where? Grepping for "base_4_17_0_0" yields only that one match.

I also found out that Cabal2nix spits out a recipe that inputs things called "base" and "aeson" and indirectly passes them to mkDerivation. I thought mkDerivation was too general to know about Haskell in particular, so where could this mapping possibly be?


Solution

  • Boot libraries like base are tied to GHC versions; see this table for the mapping. Things like haskellPackages.base are set to null because they are provided by GHC. To figure out which GHC version is in nixpkgs, you can just build it or look at the definition for haskellPackages or ghc in pkgs/top-level/all-packages.nix.

    The mkDerivation we use for Haskell isn't the generic one, it's the one defined in pkgs/development/haskell-modules/make-package-set.nix.

    P.S.: I suspect that the intersection of {people who watch Stack Overflow questions} and {people who know how the Haskell infrastructure in nixpkgs works} is exactly me, so in the future I'd recommend asking in #haskell:nixos.org.