使用Nix提取特定的Haskell程序包/阴谋依赖吗?

时间:2019-08-10 10:01:37

标签: haskell cabal nix

我遇到了类似的情况:Workarounds for Haskell / cabal packages with constraints with Nix and Cabal?

基本上,我有一个Haskell库,其依赖项为
time >= 1.9.2(阴谋软件包存储库中的时间库)。

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包,我认为这是一个乏味的过程吗?
  2. 使用cabal的本机软件包管理。我在这里担心的是,尽管它不能完全利用Nix的商店缓存,所以我最终会建立更多的库吗?我确实找到了(https://www.haskell.org/cabal/users-guide/nix-integration.html),但尚不清楚这实际上是做什么的?
  3. “越狱”时间图书馆

尝试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:

请记住,我对cabal并不了解,但是我只是在记录我尝试过的内容:

cabal new-update
Downloading the latest package list from hackage.haskell.org
To revert to previous state run:
    cabal new-update 'hackage.haskell.org,2019-08-10T14:09:42Z'
cabal new-build
Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: platinumpitanga-1.0.0.0 (user goal)
[__1] next goal: turtle (dependency of platinumpitanga)
[__1] rejecting: turtle-1.5.13/installed-1Sp... (conflict: platinumpitanga =>
time>=1.9.2, turtle => time==1.8.0.2/installed-1.8...)
[__1] trying: turtle-1.5.14
[__2] next goal: time (dependency of platinumpitanga)
[__2] rejecting: time-1.8.0.2/installed-1.8... (conflict: platinumpitanga =>
time>=1.9.2)
[__2] rejecting: time-1.9.3, time-1.9.2 (conflict: turtle => time<1.9)
[__2] rejecting: time-1.9.1, time-1.9, time-1.8.0.4, time-1.8.0.3,
time-1.8.0.2, time-1.8.0.1, time-1.8, time-1.7.0.1, time-1.7, time-1.6.0.1,
time-1.6, time-1.5.0.1, time-1.5, time-1.4.2, time-1.4.1, time-1.4.0.2,
time-1.4.0.1, time-1.4, time-1.3, time-1.2.0.5, time-1.2.0.4, time-1.2.0.3,
time-1.2.0.2, time-1.2.0.1, time-1.2, time-1.1.4, time-1.1.3, time-1.1.2.4,
time-1.1.2.3, time-1.1.2.2, time-1.1.2.1, time-1.1.2.0, time-1.0 (conflict:
platinumpitanga => time>=1.9.2)
[__2] fail (backjumping, conflict set: platinumpitanga, time, turtle)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: time, platinumpitanga, turtle
cabal new-build --allow-newer
...
Building library for lens-simple-0.1.0.9..
[1 of 1] Compiling Lens.Simple      ( Lens/Simple.hs, dist/build/Lens/Simple.o )

Lens/Simple.hs:13:7: error:
    Not in scope: `_Left'
    Perhaps you meant data constructor `Left' (imported from Prelude)
   |
13 |     , _Left, _Right
   |       ^^^^^
...

尝试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

1 个答案:

答案 0 :(得分:1)

因为最初可以使用堆栈成功构建项目,所以成功完成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 = ./.;
}