9

I'm using Nix to install packages under my home (so no binary packages) on a shared host with limited resources. I'm trying to install git-annex. When building one of its dependencies, haskell-lens, the unit tests consume so much memory that they get killed and the installation fails.

Is there a way to skip the unit tests to get the package installed? I looked at the Cabal builder and haskell-packages.nix and it seems to me that you could disable the tests by setting enableCheckPhase to false. I tried the following in ~/.nixpkgs/config.nix, but the tests are still run:

{
    packageOverrides = pkgs: with pkgs; {
        # ...other customizations...
        haskellPackages = haskellPackages.override {
            extension = self : super : {
                self.lens = self.disableTest self.lens;
            };
        };
    };
}
imz -- Ivan Zakharyaschev
  • 15,113
  • 15
  • 61
  • 123
Miikka
  • 525
  • 4
  • 13

3 Answers3

13

nixpkgs reorganized things since the accepted answer was posted and there is a new function for disabling tests. You now wrap any Haskell package with the pkgs.haskell.lib.dontCheck function to disable tests. Here is an example Nix expression from one of my Haskell projects where I had to disable tests for the shared-memory dependency when building on OS X:

{ pkgs ? import <nixpkgs> {}, compiler ? "ghc7103" }:
pkgs.haskell.packages.${compiler}.callPackage ./my-project.nix
    {   shared-memory =
            let shared-memory = pkgs.haskell.packages.${compiler}.shared-memory;
            in  if pkgs.stdenv.isDarwin
                then pkgs.haskell.lib.dontCheck shared-memory
                else shared-memory;
    }
  • Is there a way to selectively disable testing (from interactive usage perspective like `nix-build --disable-check-phase`) without changing the derivation/output hash? – CMCDragonkai Mar 26 '19 at 05:16
  • @CMCDragonkai: You cannot disable tests without changing the hash (except for fixed output derivations that have deterministic binary output). Even if you are okay with changing the hash there isn't an ergonomic way to do so from the command line that I know of – Gabriella Gonzalez Mar 28 '19 at 02:19
3

An alternative answer, addressing your concern from a different angle, is to build your packages with testing on a more powerful machine. Then when needed copy the closure to the remote host.

This works well if you are on the same architecture and the software in question is not tightly coupled to any hardware which is different on the two machines.

Read about how to share packages between machines in the nix manual.

This is nice feature which is enabled nix's approach to package management. I have often used this feature in reverse, using more powerful remote machines to build copious amounts of software for my local machine.

Davorak
  • 360
  • 1
  • 3
  • 11
2

I see you trying to use disableTest found in haskell-package.nix to remove testing from the lens packages. I would have to do some testing to tell you exactly why it is not meeting your needs.

I have disabled testing in general overriding the cabal package in config.nix to cabalNoTest. This overrides the cabal package used by the rest of the haskell packages turning off testing.

This is how I normally write it:

{
    packageOverrides = pkgs: with pkgs; {
        # ...other customizations...
        haskellPackages = haskellPackages.override {
            extension = self : super : {
                cabal = pkgs.haskellPackages.cabalNoTest;
            };
        };
    };
}
Davorak
  • 360
  • 1
  • 3
  • 11