nmattia / niv

Easy dependency management for Nix projects
https://github.com/nmattia/niv
MIT License
1.56k stars 77 forks source link

niv source for hlint throws called without required argument 'ghc-lib-parser-ex' #249

Closed codygman closed 4 years ago

codygman commented 4 years ago

First I tried this code with shelllcheck and it worked:

# test-shellcheck-overlay.nix
{ sources ? import ./nixpkgs/nix/sources.nix }:     # import the sources
with
  { overlay = _: pkgs:
      { niv = import sources.niv {};    # use the sources :)
        shellcheck = pkgs.haskellPackages.callCabal2nix "shellcheck" sources.shellcheck {};
      };
  };
let mypkgs = import sources.nixpkgs { overlays = [ overlay ]; };
in mypkgs.mkShell {
  buildInputs = [
    mypkgs.shellcheck # when shellcheck overlay present we go from 0.7.0 to 0.7.1
  ]; }

Then I tried with hlint since I knew it could possibly be more complicated and depend on boot packages or ghc version specific things:

# test-niv-overlay.nix
{ sources ? import ./nixpkgs/nix/sources.nix }:     # import the sources
with
  { overlay = _: pkgs:
      { niv = import sources.niv {};    # use the sources :)
        hlint = pkgs.haskellPackages.callCabal2nix "hlint" sources.hlint { };
      };
  };
let mypkgs = import sources.nixpkgs { overlays = [ overlay ]; };
in mypkgs.mkShell {
  buildInputs = [
    # without overlay this gives 2.2.2, after it should give 3.1.6 using
    # nix-shell test-niv-overlay.nix --run "hlint --version"
    mypkgs.hlint # should be 3.1.6 but it's not
  ]; }

It returns:

-*- mode: compilation; default-directory: "~/hci/" -*-
Compilation started at Sat Jul 18 23:18:52

nix-shell test-niv-overlay.nix --run "hlint --version"
error: anonymous function at /nix/store/2cvhh84x9jycqpgbxxpsq46qyyhbijbv-cabal2nix-hlint/default.nix:1:1 called without required argument 'ghc-lib-parser-ex', at /nix/store/08xfivmynisgv4lxp4d9x457x8a1qhcp-source/pkgs/development/haskell-modules/make-package-set.nix:87:27
(use '--show-trace' to show detailed location information)

Compilation exited abnormally with code 1 at Sat Jul 18 23:18:53

I have a feeling maybe I can provide ghc-lib-parser-ex... maybe via a different overlay.. but I'm not sure if that should be necessary.

nmattia commented 4 years ago

Hi! So, I'm not sure this is really a niv issue but I can try to help. When you're using callCabal2nix, it generates a nix file that takes hlint's dependencies as arguments, and then (IIRC) uses callPackage (the haskell one) on that. So that means your haskell package set does not have ghc-lib-parser-ex. There are various ways to add packages, but most likely you'll need to override the haskell package set. This ticket and the manual are good starting points.