Override haskell package in default.nix

I’m trying to migrate an old project of mine from stack to nix and need to override one of the libraries, llvm-hs-pretty and stop it from running tests, as they’re broken. I have the following default.nix, but it still tries to run the test upon entering nix-shell.

let
  config = {
    packageOverrides = pkgs: rec {
      haskellPackages = pkgs.haskellPackages.override {
        overrides = haskellPackagesNew: haskellPackagesOld: rec {
          llvm-hs-pretty =
            pkgs.haskell.lib.dontCheck haskellPackagesOld.llvm-hs-pretty;
        };
      };
    };
    allowBroken = true;
  };
  pkgs = import <nixpkgs> { inherit config; };
  compilerVersion = "ghc883";
  compiler = pkgs.haskell.packages."${compilerVersion}";
  pkg = compiler.developPackage {
    root = ./.;
    source-overrides = { };
    modifier = drv:
      pkgs.haskell.lib.addBuildTools drv
      (with pkgs.haskellPackages; [ cabal-install alex happy ]);
  };
  buildInputs = [ pkgs.llvm_9 pkgs.clang_9 ];
in pkg.overrideAttrs
(attrs: { buildInputs = attrs.buildInputs ++ buildInputs; })

I managed to figure it out. The key was to override the package set for ghc-8.8.3 specifically. This works for getting a nix-shell development environment working:

let
  compilerVersion = "ghc883";
  config = {
    packageOverrides = pkgs: rec {
      haskell = pkgs.haskell // {
        packages = pkgs.haskell.packages // {
          ghc883 = pkgs.haskell.packages."${compilerVersion}".override {
            overrides = self: super: {
              llvm-hs-pretty = pkgs.haskell.lib.dontCheck super.llvm-hs-pretty;
            };
          };
        };
      };
    };
    allowBroken = true;
  };
  pkgs = import <nixpkgs> { inherit config; };
  compiler = pkgs.haskell.packages."${compilerVersion}";
  pkg = compiler.developPackage {
    root = ./.;
    source-overrides = { };
    modifier = drv:
      pkgs.haskell.lib.addBuildTools drv
      (with pkgs.haskellPackages; [ cabal-install alex happy ]);
  };
  buildInputs = [ pkgs.llvm_9 pkgs.clang_9 ];
in pkg.overrideAttrs
(attrs: { buildInputs = attrs.buildInputs ++ buildInputs; })
1 Like