Nixpkgs: Improve handling of rubbish in ghcWithPackages

Created on 11 Oct 2017  路  4Comments  路  Source: NixOS/nixpkgs

Issue description

When you pass something bogus into ghcWithPackages, it succeeds instead of failing loudly.

Steps to reproduce

Write

nix-build --expr 'with import ./. {}; with import ./pkgs/development/haskell-modules/lib.nix { inherit pkgs lib; }; haskellPackages.ghcWithPackages (pkgs: with pkgs; [ dontCheck consul-haskell ])'

Debug an hour why it doesn't work (it builds the package with tests, ignoring dontCheck).

Realise that [ dontCheck consul-haskell ] should have been [ (dontCheck consul-haskell) ].


From @cleverca22

i would also expect ghcWithPackages to fail hard, because you gave it a lambda when it was expecting a string/package
so i'm surprised it even tried to build it

[clever@amd-nixos:~/apps/nixpkgs]$ nix-repl .
Welcome to Nix version 1.11.14. Type :? for help.

Loading '.'...
Added 7948 variables.

nix-repl> builtins.unsafeGetAttrPos "dontCheck" haskell.lib
{ column = 3; file = "/home/clever/apps/nixpkgs/pkgs/development/haskell-modules/lib.nix"; line = 24; }
nix-repl> builtins.unsafeGetAttrPos "ghcWithPackages" haskellPackages
{ column = 5; file = "/home/clever/apps/nixpkgs/pkgs/development/haskell-modules/make-package-set.nix"; line = 164; }

pkgs/development/haskell-modules/with-packages-wrapper.nix

paths = lib.filter (x: x ? isHaskellLibrary) (lib.closePropagation packages);

aha

nix-repl> haskellPackages.consul-haskell.isHaskellLibrary
true

if you give ghcWithPackages anything that lacks a .isHaskellLibrary attribute, it will silently filter it out of the package list


Technical details

  • Nixpkgs version: dea58ce228e6f9686773745024eb844d8dc39fc3
bug stale haskell

All 4 comments

CC @cleverca22 @peti -- Ideally we could make it fail loudly on such errors.

Yeah, that's a good point. I suppose we could throw an error if any non-Haskell packages are included in the package list.

Filtering non-Haskell packages is a bit too agressive, one might have developer tools installed around.

I suggest we assert on non-derivations to catch errors like this.

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.
Was this page helpful?
0 / 5 - 0 ratings

Related issues

yawnt picture yawnt  路  3Comments

retrry picture retrry  路  3Comments

tomberek picture tomberek  路  3Comments

ayyess picture ayyess  路  3Comments

matthiasbeyer picture matthiasbeyer  路  3Comments