4

不幸的是,在 NixOS 上安装 haskell 包“Euterpea”失败:

Nixpkgs 手册指出,所有在hackage 上注册的 haskell 包(Euterpea 包是)都包含在 nix 包管理器中,并且必须像这样安装:

nix-env -f "<nixpkgs>" -iA haskellPackages.Euterpea

一些下载和编译后,出现如下错误,进程中断:

[ 7 of 46] Compiling Euterpea.IO.MIDI.MidiIO ( Euterpea/IO/MIDI/MidiIO.lhs, dist/build/Euterpea/IO/MIDI/MidiIO.o )

Euterpea/IO/MIDI/MidiIO.lhs:153:25:
    Not in scope: ‘Heap.extractHead’

Euterpea/IO/MIDI/MidiIO.lhs:160:34: Not in scope: ‘Heap.head’
builder for ‘/nix/store/wc8d02s0kin4l0siwixlylssizfsrzgx-Euterpea-1.1.1.drv’ failed with exit code 1
error: build of ‘/nix/store/wc8d02s0kin4l0siwixlylssizfsrzgx-Euterpea-1.1.1.drv’ failed

有谁知道如何解决这个问题?

4

1 回答 1

2

这里的问题是Euterpea它不能针对 nixpkgs 中可用的最新版本的依赖项进行编译。这是一个可以成功构建的表达式Euterpea(在当前的 nixpkgs 上测试不稳定):

将以下 nix 表达式写入名为 的文件中euterpea.nix

# let's get nixpkgs into scope
with (import <nixpkgs> {});

let
  lib = haskell.lib;

  # build a "package set" (collection of packages) that has the correct versions of the dependencies
  # needed by Euterpea
  customHaskellPackages = haskellPackages.override (old: {
    overrides = self: super: {
        heap = self.callHackage "heap" "0.6.0" {}; 
        PortMidi = self.callHackage "PortMidi" "0.1.5.2" {};
        stm = self.callHackage "stm" "2.4.2" {};
    };
  });
in {
  # this is a ghc wrapper that has only Euterpea as its visible packages
  ghc = customHaskellPackages.ghcWithPackages (pkgs: [ pkgs.Euterpea ]);

  # this is just the output of the build for Euterpea 
  pkg = customHackagePackages.Euterpea;

  # for convenience, also expose the package set that we build against
  pkgset = customHaskellPackages;
}

然后您可以运行以下命令:

$ nix-build euterpea.nix -A ghc # build a GHC with the Euterpea package included
/nix/store/mjlp6rxcsiv5w8ay1qp0lrj8m40r3cyl-ghc-8.0.1-with-packages
$ result/bin/ghci # result contains a GHC installation that has Euterpea, so we can run GHCI from it
GHCi, version 8.0.1: http://www.haskell.org/ghc/  :? for help
Loaded GHCi configuration from /home/.ghci
λ: import Euterpea
λ: 
Leaving GHCi.
$ nix-env --install --file euterpea.nix -A ghc # we can also install this ghc into our user environment
installing ‘ghc-8.0.1-with-packages’
building path(s) ‘/nix/store/7jwrwxaxyig6hf747rsan5514gw7qi51-user-environment’
created 5840 symlinks in user environment
$ 
于 2017-01-14T14:22:47.370 回答