haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Attribute 'hsc2hs' missing

Open ttuegel opened this issue 5 years ago • 6 comments

(For reference, I am working with ttuegel/kore, but I have pasted the relevant Nix expressions here.)

I use stack-to-nix to generate pkgs.nix, which I import into default.nix:

let sources = import ./nix/sources.nix; in
let overlay = _: pkgs: { niv = import sources."niv" {}; }; in
let nixpkgs = import sources."nixpkgs" { overlays = [ overlay ]; config = {}; }; in
# Import haskell.nix rev 3d79fa95205c6877521118cde3a36b90ce273a02 using niv.
let haskell = import sources."haskell.nix" {}; in
let inherit (nixpkgs.nix-gitignore) gitignoreSourcePure; in
let
  pkgSet = haskell.mkStackPkgSet {
    stack-pkgs = import ./nix/pkgs.nix;
    modules = [
      # TODO: Modify existing `src' attribute instead?
      { packages.kore.src = gitignoreSourcePure [./.gitignore] ./kore; }
    ];
  };
in

{
  inherit (haskell) nix-tools;
  inherit (nixpkgs) niv;
  inherit (pkgSet.config) hsPkgs;
}

nix build -f . hsPkgs.kore.components.tests.kore-test --show-trace fails with:

error: while evaluating the attribute 'CABAL_CONFIG' of the derivation 'kore-0.0.1.0-test-kore-test' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/comp-builder.nix:113:3:
while evaluating the attribute 'buildCommand' of the derivation 'kore-0.0.1.0-test-kore-test-config' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'concatMapStringsSep' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/strings.nix:88:5, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:69:7:
while evaluating 'flatLibDepends' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/lib/default.nix:89:20, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:71:10:
while evaluating the attribute 'CABAL_CONFIG' of the derivation 'hedgehog-0.6.1-lib-hedgehog' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/comp-builder.nix:113:3:
while evaluating the attribute 'buildCommand' of the derivation 'hedgehog-0.6.1-lib-hedgehog-config' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'concatMapStringsSep' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/strings.nix:88:5, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:69:7:
while evaluating 'flatLibDepends' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/lib/default.nix:89:20, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:71:10:
while evaluating the attribute 'CABAL_CONFIG' of the derivation 'concurrent-output-1.10.9-lib-concurrent-output' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/comp-builder.nix:113:3:
while evaluating the attribute 'buildCommand' of the derivation 'concurrent-output-1.10.9-lib-concurrent-output-config' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/pkgs/build-support/trivial-builders.nix:7:14:
while evaluating 'concatMapStringsSep' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/strings.nix:88:5, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:69:7:
while evaluating 'flatLibDepends' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/lib/default.nix:89:20, called from /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/make-config-files.nix:71:10:
while evaluating the attribute 'nativeBuildInputs' of the derivation 'terminal-size-0.3.2.1-lib-terminal-size' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/builder/comp-builder.nix:113:3:
while evaluating 'chooseDevOutputs' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/attrsets.nix:474:22, called from undefined position:
while evaluating the attribute 'build-tools' at undefined position:
while evaluating anonymous function at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:75:45, called from undefined position:
while evaluating the attribute 'value' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:338:9:
while evaluating the option `packages.terminal-size.components.library.build-tools':
while evaluating the attribute 'mergedValue' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:370:5:
while evaluating anonymous function at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:370:32, called from /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:370:19:
while evaluating 'merge' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/modules/plan.nix:23:18, called from /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:373:8:
while evaluating anonymous function at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/modules/plan.nix:24:33, called from undefined position:
while evaluating anonymous function at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/lists.nix:103:29, called from undefined position:
while evaluating anonymous function at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/modules/plan.nix:26:21, called from /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/lists.nix:103:32:
while evaluating the attribute 'optionalValue' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:377:5:
while evaluating the attribute 'values' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:364:9:
while evaluating the attribute 'values' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:458:7:
while evaluating anonymous function at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:350:28, called from /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:350:17:
while evaluating 'dischargeProperties' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:417:25, called from /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/lib/modules.nix:351:62:
while evaluating the attribute 'value' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/modules/plan.nix:30:38:
while evaluating the attribute 'buildPackages.hsc2hs' at /nix/store/sv3k6axx9hmn9l8l33lqgpsplpksky02-source/modules/component-driver.nix:53:7:
while evaluating the attribute 'buildPackages.hsc2hs' at /nix/store/k424784n1gqjks4nzg70p8rmd59hcq8i-nixpkgs/pkgs/top-level/stage.nix:74:5:
attribute 'hsc2hs' missing, at /nix/store/vbva59dnmjyss0sbqc6xkaqawkw3l720-hackage-exprs-source/hackage/terminal-size-0.3.2.1-r0-7b2d8e0475a46961d07ddfb91dee618de70eff55d9ba0402ebeac1f9dcf9b18b.nix:23:44

The referenced expression for terminal-size-0.3.2.1 is:

{ system, compiler, flags, pkgs, hsPkgs, pkgconfPkgs, ... }:
  {
    flags = {};
    package = {
      specVersion = "1.10";
      identifier = { name = "terminal-size"; version = "0.3.2.1"; };
      license = "BSD-3-Clause";
      copyright = "";
      maintainer = "[email protected]";
      author = "Andreas Hammar, Matvey Aksenov";
      homepage = "";
      url = "";
      synopsis = "Get terminal window height and width";
      description = "Get terminal window height and width without ncurses dependency.";
      buildType = "Simple";
      };
    components = {
      "library" = {
        depends = ([
          (hsPkgs.base)
          ] ++ (pkgs.lib).optional (compiler.isGhc && ((compiler.version).ge "7.2" && (compiler.version).lt "7.6")) (hsPkgs.ghc-prim)) ++ (pkgs.lib).optional (system.isWindows) (hsPkgs.process);
        build-tools = [
          (hsPkgs.buildPackages.hsc2hs or (pkgs.buildPackages.hsc2hs))
          ];
        };
      };
    }

I think hsc2hs should be bundled with GHC, isn't that right?

ttuegel avatar Jul 27 '19 20:07 ttuegel

Hi, thanks for the report. The handling of hsc2hs needs to be fixed.

Would you be able to work around this for now by adding hsc2hs to the extra-deps of kore/stack.yaml?

rvl avatar Jul 27 '19 22:07 rvl

@ttuegel

I think hsc2hs should be bundled with GHC, isn't that right?

This is correct. With haskell.nix we try to rely as little on stuff that ghc is supposed to ship with. We could just null out hsc2hs, and rely on the one ghc bundles. But it would prevent you from patching hsc2hs (or any other tool ghc ships with) without having to rebuild ghc (and everything that entails) all over again.

The fundamental reason why you are hitting this is that the stack snapshot doesn't include hsc2hs, and thus we can't find it.

And alternative route, which I think might be sensible in haskell.nix is to provide an overlay (See #210), that is essentially

self: super: {
  # null out hsc2hs, and rely on the one that comes with the `ghc` derivation.
  # We will still preferably try to pick the one from the `hsPkgs` set, and thus
  # allow the end user to specify which version (and patches) to use, but fall
  # back on the one in the ghc distribution.
  hsc2hs = null;
}

this should provide the necessary attribute for the alternate case of pkgs.buildPackages.hsc2hs.

angerman avatar Jul 28 '19 06:07 angerman

Would you be able to work around this for now by adding hsc2hs to the extra-deps of kore/stack.yaml?

For non-technical reasons, I need to do this without modifying stack.yaml. I'm working around this for now by this addition to pkg-def-extras:

haskell.mkStackPkgSet {
    # ...
    pkg-def-extras = [
      (hackage: { hsc2hs = hackage.hsc2hs."0.68.4".revisions.default; })
    ];
}

I had to go digging in the source of hackage.nix to discover the correct incantation here, so perhaps I should add a blurb to the manual?

ttuegel avatar Jul 28 '19 18:07 ttuegel

@angerman for the life of me I could not figure out the right place to put an overlay with hsc2hs = null that would actually work. If you want to paste a fuller working example, that would be great — but no pressure, since @ttuegel 's solution ended up working for me.

In related news, I just tried to use haskell.nix on haddock, and was met with attribute 'ghc-boot' missing. The same fix, adding an entry in pkg-def-extras, seems to have done the trick, as it's now building.

chreekat avatar Aug 14 '19 15:08 chreekat

FWIW, I hit the same problem with ghc-compact (which I assume is bundled with GHC as well), so replicating @ttuegel's solution

haskell.mkStackPkgSet {
    # ...
    pkg-def-extras = [
      (hackage: { ghc-compact = hackage.ghc-compact."0.1.0.0".revisions.default; })
    ];
}

solved it.

pkamenarsky avatar Aug 21 '19 21:08 pkamenarsky

ghc-boot will be fixed in https://github.com/input-output-hk/haskell.nix/pull/233

domenkozar avatar Sep 07 '19 12:09 domenkozar