How do I overwrite ghc compiler version?

Hi. I’ve been searching for this topic a lot and I’ve found some clues but I’m still not sure about how I would overwrite ghc compiler version with Nix. I want to build a project with ghc 8.10.1 but the default in right now is 8.8.3. I have a packages.nix file which I use to override haskell packages. So I’m assuming I would do it there

    nixpkgs = import <nixpkgs> { inherit config; };
    config = {
      allowBroken = true;
      packageOverrides = pkgs:
          hl = pkgs.haskell.lib;
          t = pkgs.lib.trivial;
          dontAndDisable = (t.flip t.pipe)
        in rec {
          haskellPackages = pkgs.haskellPackages.override {
            overrides = self: super: {

I’m not really doing Haskell stuff, but won’t it be easier for you to just use haskell.packages.ghc8101 instead of messing with overriding the default ghc?


Probably is the way to go. I see now that I can do

nix-build -p haskell.compiler.ghc8101

for some reason I thought I would have to overwrite this option in the config files but passing this seems to do it.