Skip to content

haskellPackages.shellFor with hoogle enabled fails with null dependencies #82245

@alexpeits

Description

@alexpeits

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    0.kind: bugSomething is broken2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: haskellGeneral-purpose, statically typed, purely functional programming language
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions