I’m using NixOS 21.05. I have a directory with just the following two files:
$ cat default.nix
let
pkgs = import <nixpkgs> { };
in
pkgs.haskellPackages.developPackage {
root = ./.;
modifier = drv:
pkgs.haskell.lib.addBuildTools drv (with pkgs.haskellPackages;
[ cabal-install
]);
}
$ cat amy-test.cabal
cabal-version: 2.4
name: amy-test
version: 1.0
library
exposed-modules: MyLib
build-depends: base >=4.7 && <5
hs-source-dirs: src
default-language: Haskell2010
-- -- UNCOMMENT THIS BLOCK AND nix-shell SUCCEEDS
-- test-suite gray-extended-test
-- default-language: Haskell2010
-- type: exitcode-stdio-1.0
-- hs-source-dirs: test
-- main-is: TestMain.hs
-- build-depends:
-- , base
-- , gray-extended
-- , test-framework
If I invoke nix-shell without a test-suite section in the cabal file, I get an error:
$ nix-shell --show-trace
error: while evaluating the attribute 'NIX_GHC' of the derivation 'ghc-shell-for-amy-test-1.0' at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'paths' of the derivation 'ghc-8.10.4-with-packages' at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating the attribute 'buildCommand' of the derivation 'hoogle-local-0.1' at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/stdenv/generic/make-derivation.nix:201:11:
while evaluating 'optionalString' at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/lib/strings.nix:202:5, called from /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/development/haskell-modules/hoogle.nix:66:7:
while evaluating 'concatMapStringsSep' at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/lib/strings.nix:110:5, called from /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/development/haskell-modules/hoogle.nix:69:10:
while evaluating anonymous function at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/development/haskell-modules/hoogle.nix:69:40, called from undefined position:
value is null while a set was expected, at /nix/store/g2bm5amvm77m4w9gbf5g1wzbw22hyam2-nixos-21.05.1669.973910f5c31/nixos/pkgs/development/haskell-modules/hoogle.nix:69:43
However, if I add a test suite section (uncommenting it in the cabal file), nix-shell succeeds. Is this a bug, or is there something I don’t understand about nix? I normally do have test-suite sections in all my cabal files, but I ran into this issue while trying to debug another problem.