在NixOs上安装Haskell包Euterpea失败

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

有人有修复这个问题的想法吗?

Euterpea-1.1.1 看起来你的 nixpkgs 已经过时了,但这可能与问题无关。当我运行你的命令(使用 Euterpea 2.0.2)时,出现了配置错误。 - danbst
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
$ 

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接