Nixpkgs: haskellPackages.shellFor with hoogle enabled fails with null dependencies

Created on 10 Mar 2020  路  5Comments  路  Source: NixOS/nixpkgs

Describe the bug
On the nixpkgs-unstable branch, when there are no haskell dependencies other than base (and other common ones like text) in build-depends in the cabal file, starting a shell with hoogle enabled gives the error:

error: value is null while a set was expected, at /nix/store/<hash>-source/pkgs/development/haskell-modules/hoogle.nix:69:43

To Reproduce
Steps to reproduce the behavior:

  1. Create the following default.nix:
{ pkgs ? import <nixpkgs> {} }:

let

  nixpkgs-src = pkgs.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs";
    rev = "nixpkgs-unstable";
    sha256 = "06755h2cxrsgrsiclxbk3h5d7yqajvjjq3y4pl1dqbxfbjhq0h67";
  };
  nixpkgs = import nixpkgs-src {};

  haskellPackages = nixpkgs.haskellPackages.override {
    overrides = self: super:
      { testpkg = self.callCabal2nix "testpkg" ./. {}; };
  };

  shell = haskellPackages.shellFor {
    packages = ps: [ ps.testpkg ];
    buildInputs = [ haskellPackages.cabal-install ];
    withHoogle = true;
  };

in

if nixpkgs.lib.inNixShell then shell else haskellPackages.testpkg
  1. The following testpkg.cabal:
cabal-version: 2.2

name:           testpkg
version:        0.1.0.0
description:    testpkg
build-type:     Simple

library
  exposed-modules:
  other-modules:
      Paths_testpkg
  hs-source-dirs:
      src
  build-depends:
      base >=4.7 && <5
      -- uncomment the following to make it work
      -- , lens 
  default-language: Haskell2010
  1. run nix-shell

Expected behavior
The nix shell is initialized, and running hoogle server --local runs a hoogle server. Adding another dependency in build-depends, e.g. lens, results in the expected behaviour.

Additional context
The issue seems similar to this closed issue

Metadata

these paths will be fetched (0.00 MiB download, 0.00 MiB unpacked):
  /nix/store/4cr2bqya0an66mpqpj195z49453qm8f6-nix-info
copying path '/nix/store/4cr2bqya0an66mpqpj195z49453qm8f6-nix-info' from 'https://cache.nixos.org'...
 - system: `"x86_64-linux"`
 - host os: `Linux 4.15.0-88-generic, Ubuntu, 16.04.6 LTS (Xenial Xerus)`
 - multi-user?: `no`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.2.1`
 - channels(alex): `"nixpkgs-20.03pre211462.0c960262d15"`
 - nixpkgs: `/<redacted>/.nix-defexpr/channels/nixpkgs`

Maintainer information:

# a list of nixpkgs attributes affected by the problem
attribute: 
  - haskellPackages.shellFor
bug haskell

All 5 comments

Ping @Ericson2314.

It is possible this was introduced in either https://github.com/NixOS/nixpkgs/pull/80845 or https://github.com/NixOS/nixpkgs/pull/76349.

Also ping @jmininger and @matthewbauer, who did reviews on these issues.


Also, @alexpeits, if you'd like to look into this, I'm hoping the fix wouldn't be too tricky.

Surprisingly what causes the issue is this warning message https://github.com/NixOS/nixpkgs/blob/001be890f78f04df86938f44c0761676e299ceac/pkgs/development/haskell-modules/hoogle.nix#L66-L69
(if I remove the concatMapStringsSep call it works). Seems like packages is a list which contains a null for some reason that I can't figure out, but I'll look into it a bit more

I had the same issue, previous suggestion worked.

https://github.com/NixOS/nixpkgs/pull/42368/files this revert would seem to reintroduce the issue, but the issue was not reopened.

Today I experienced this error with nixos-20.03, which is weird given that by reading this thread I got the idea that this was already fixed.

Edit: I think this is because the package I was using does not have an executable, but the package only depends on base. How can I work around this?
Here's my derivation:

  shell = myHaskellPackages.shellFor {
    packages = p: [
      p."laop"
    ];
    buildInputs = with pkgs.haskellPackages; [
      myHaskellPackages.cabal-install
      pkgs.neo4j
      (import sources.niv {}).niv
      pkgs.nixpkgs-fmt
    ];
    withHoogle = true;
  };
Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

langston-barrett picture langston-barrett  路  3Comments

rzetterberg picture rzetterberg  路  3Comments

spacekitteh picture spacekitteh  路  3Comments

ayyess picture ayyess  路  3Comments