Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable building and running tests for all Haskell dependencies in a Nix build

Tags:

haskell

cabal

nix

Disabling the testsuite for my own cabal project is easy with cabal2nix, just supply --no-check. What about my project's dependencies? How can I disable compiling and running their testuites while building them?

Overriding each dependency (recursively!) with noCheck = false seems tedious. Is there some kind of overlay mechanism available?

like image 617
Sebastian Graf Avatar asked Sep 21 '25 01:09

Sebastian Graf


1 Answers

There is indeed! To change something recursively for all packages, you can override the thing that generates all packages, and that's haskellPackages.mkDerivation. So this is doable with a Haskell package overlay like this:

hself: hsuper: {
  mkDerivation = args: hsuper.mkDerivation (args // {
    doCheck = false;
  });
}

You can also override other arguments from here like this. For example you can disable library profiling builds, which commonly halves the build time:

hself: hsuper: {
  mkDerivation = args: hsuper.mkDerivation (args // {
    enableLibraryProfiling = false;
  });
}

See this section in the manual for more info.

Edit: If you want to use this as a user overlay, you can put the following in ~/.config/nixpkgs/overlays/haskell-no-check.nix:

self: super: {
  haskell = super.haskell // {
    packageOverrides = hself: hsuper: {
      mkDerivation = args: hsuper.mkDerivation (args // {
        doCheck = false;
      });
    };
  };
}

Note that this uses haskell.packageOverrides, not the somewhat deprecated packageOverrides in config.nix.

There are other ways of doing it, but I think in this case this is the best because it applies the change to all Haskell package sets. Unfortunately due to how overriding works, this would clear previous packageOverrides, which often isn't a problem, but can be. If you need to persist previous ones, then you can do this:

self: super: {
  haskell = super.haskell // {
    packageOverrides = super.lib.composeExtensions super.haskell.packageOverrides
      (hself: hsuper: {
        mkDerivation = args: hsuper.mkDerivation (args // {
          doCheck = false;
        });
      });
  };
}
like image 56
Silvan Mosberger Avatar answered Sep 23 '25 00:09

Silvan Mosberger