Ghc version in 'cabal run'

When I execute the command cabal run MyProject in a nix shell, the first line that gets printed is

Build profile: -w ghc-8.10.4.20210212 -O1

Where does the ghc version come from? It is set nowhere in MyProject.cabal or in cabal.project.

I would like to run the command with the newest version of ghc. How can I achieve this?

Probably, the ghc version comes from the nixpkgs your nix shell is using. It depends on what your nix shell script looks like. You should be able to choose packages using haskell.packages.${ghcversion} inside the nixpkgs attrset. I think if you just use haskell.packages it defaults to whatever ghc was considered stable in the nixpkgs you’re using. If the right ghc is not in your nixpkgs probably should update your nixpkgs. I forget how that’s done pre-flakes, and I don’t know niv either.

If you’re looking for the latest ghc version I just googled this maybe you can try it, or use what you need from it ghc.nix/default.nix at master · alpmestan/ghc.nix · GitHub

2 Likes