Nix构建无法构建Haskell包“由于来自Cabal的严重配置时警告而中止”“未找到uhc”

jfewjypa  于 2023-03-13  发布在  其他
关注(0)|答案(2)|浏览(219)

我遇到过类似的情况:Workarounds for Haskell / cabal packages with constraints with Nix and Cabal?
实际上,我有一个Haskell库,它依赖于
time >= 1.9.2(cabal软件包存储库中的时间库)。
nixpkgs中当前似乎不存在此版本,执行nix build会导致以下错误:

...
CallStack (from HasCallStack):
  die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:950:20 in Cabal-2.4.0.1:Distribution.Simple.Configure
  configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:460:12 in Cabal-2.4.0.1:Distribution.Simple.Configure
  configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:596:20 in Cabal-2.4.0.1:Distribution.Simple
  confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.4.0.1:Distribution.Simple.UserHooks
  configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:178:19 in Cabal-2.4.0.1:Distribution.Simple
  defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:115:27 in Cabal-2.4.0.1:Distribution.Simple
  defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing dependencies:
time >=1.9.2
...

这里有什么可能的解决方案?我还注意到以下问题,但不确定是否相关:https://github.com/haskell/cabal/issues/5223
我想到的可能解决方案:
1.覆盖Haskell time包,我想这是一个乏味的过程吧?
1.使用cabal的原生软件包管理。我担心的是它不能充分利用Nix的存储缓存,所以我最终会构建更多的库?我确实找到了(https://www.haskell.org/cabal/users-guide/nix-integration.html),但不清楚它实际上是做什么的?
1.“越狱"时间图书馆
尝试1:

myHaskellPackages = haskellPackages.override {
    overrides = self: super: rec {
      time  = self.callCabal2nix "time" (builtins.fetchGit {
        url = "git@github.com:haskell/time.git";
        rev = "5d2046f79cf5451f48b17529abec85349333aa9f";
      }) {};
    };
  };

  variant = if doBenchmark then myHaskellPackages.lib.doBenchmark else pkgs.lib.id;

  drv = variant (myHaskellPackages.callPackage f {});

奇怪的结果是:

nix-shell
error: infinite recursion encountered, at undefined position
(use '--show-trace' to show detailed location information)

尝试2:
我没有彻底了解阴谋集团,但我只是在记录我所尝试的:
一个一个三个一个一个一个一个一个四个一个一个一个一个一个五个一个
尝试3:

myHaskellPackages = pkgs.haskellPackages.override {
    overrides = self: super: rec {
      turtle = pkgs.haskell.lib.doJailbreak super.turtle;
    };
  };

似乎导致了相同的错误:

...
CallStack (from HasCallStack):
  die', called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:950:20 in Cabal-2.4.0.1:Distribution.Simple.Configure
  configureFinalizedPackage, called at libraries/Cabal/Cabal/Distribution/Simple/Configure.hs:460:12 in Cabal-2.4.0.1:Distribution.Simple.Configure
  configure, called at libraries/Cabal/Cabal/Distribution/Simple.hs:596:20 in Cabal-2.4.0.1:Distribution.Simple
  confHook, called at libraries/Cabal/Cabal/Distribution/Simple/UserHooks.hs:67:5 in Cabal-2.4.0.1:Distribution.Simple.UserHooks
  configureAction, called at libraries/Cabal/Cabal/Distribution/Simple.hs:178:19 in Cabal-2.4.0.1:Distribution.Simple
  defaultMainHelper, called at libraries/Cabal/Cabal/Distribution/Simple.hs:115:27 in Cabal-2.4.0.1:Distribution.Simple
  defaultMain, called at Setup.hs:2:8 in main:Main
Setup: Encountered missing dependencies:
time >=1.9.2

builder for '/nix/store/67109ylsjfw8vpdv0q5b90d2bwx8zii0-platinumpitanga-1.0.0.0.drv' failed with exit code 1
error: build of '/nix/store/67109ylsjfw8vpdv0q5b90d2bwx8zii0-platinumpitanga-1.0.0.0.drv' failed

更新...
因此,显然覆盖像time这样的“core”库实际上并不起作用(?)...我尝试定义如下内容:

myHaskellPackages = pkgs.haskell.packages.${compiler}.override {
    overrides = self: super: rec {
      timezz = pkgs.haskell.packages.${compiler}.callHackageDirect
        {
          pkg = "time";
          ver = "1.9.3";
          sha256 = "1bs74nj2qc83i2d78xf1hn79f37g8wjgak2bwn5bnwb31pl0bl7r";
        }
        {};
    };
  };

然后使用timezz作为依赖项,而不是time ...但无法构建时间库,原因是:

Documentation installed in:
/nix/store/9s5hbq3pzippwcylb3x501rja2vxip1c-platinumpitanga-1.0.0.0-doc/share/doc/platinumpitanga-1.0.0.0
Configuration files installed in:
/nix/store/26qkhjjq0ry8mxx6myp0h7m21d35x84z-platinumpitanga-1.0.0.0/etc
No alex found
Using ar found on system at:
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/ar
No c2hs found
No cpphs found
No doctest found
Using gcc version 7.4.0 given by user at:
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin/gcc
Using ghc version 8.6.4 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/ghc
Using ghc-pkg version 8.6.4 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/ghc-pkg
No ghcjs found
No ghcjs-pkg found
No greencard found
Using haddock version 2.22.0 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/haddock
No happy found
Using haskell-suite found on system at: haskell-suite-dummy-location
Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location
No hmake found
Using hpc version 0.67 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/hpc
Using hsc2hs version 0.68.5 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/hsc2hs
Using hscolour version 1.24 found on system at:
/nix/store/xnn0093zfkxsvjyr6g7w1l534hrb1p57-hscolour-1.24.4/bin/HsColour
No jhc found
Using ld found on system at:
/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin/ld
No pkg-config found
Using runghc version 8.6.4 found on system at:
/nix/store/gvshp9yvc6gql09r3cyryj2zgsnfk6br-ghc-8.6.4/bin/runghc
Using strip version 2.31 found on system at:
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin/strip
Using tar found on system at:
/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin/tar
No uhc found
*** abort because of serious configure-time warning from Cabal
builder for '/nix/store/3dsr8m5frzyn0lcmf4v0b80fq55b2vp6-platinumpitanga-1.0.0.0.drv' failed with exit code 1
error: build of '/nix/store/3dsr8m5frzyn0lcmf4v0b80fq55b2vp6-platinumpitanga-1.0.0.0.drv' failed
j0pj023g

j0pj023g1#

由于项目最初可以使用stack成功构建......导致nix-build --option sandbox false成功的变通方案是:

{
  nixpkgs ? import <nixpkgs> {}
, sources ? import ./nix/sources.nix
, compiler ? "ghc864" } :
let
  niv = import sources.nixpkgs {
    overlays = [
      (_ : _ : { niv = import sources.niv {}; })
    ] ;
    config = {};
  };
  pkgs = niv.pkgs;
in
pkgs.haskell.lib.buildStackProject {
  name = "platinumpitanga";
  src = ./.;
}
nzrxty8p

nzrxty8p2#

在我的例子中,“没有找到uhc”、“没有找到pkg-config”等错误是转移注意力的。
真实的的错误在完整日志中:

...
Warning:
    This package indirectly depends on multiple versions of the same package. This is very likely to cause a compile failure.
      package template-haskell (template-haskell-2.18.0.0) requires ghc-boot-th-9.2.6
      package template-haskell (template-haskell-2.19.0.0-2658Yx2CP4h94J3uUoFLJy) requires ghc-boot-th-9.4.1-9qWq7wqwtEsCm8IbSoKFQI
      package bytestring (bytestring-0.11.4.0) requires template-haskell-2.18.0.0
      package QuickCheck (QuickCheck-2.14.2) requires template-haskell-2.19.0.0-2658Yx2CP4h94J3uUoFLJy
...

相关问题