【问题标题】:Installation of Haskell Package Euterpea fails on NixOs在 NixOs 上安装 Haskell 包 Euterpea 失败
【发布时间】:2017-04-13 15:48:57
【问题描述】:

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

Nixpkgs manual 声明所有在 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)

标签: haskell nixos euterpea


【解决方案1】:

这里的问题是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
$ 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-01-28
    • 2020-01-05
    • 2013-03-20
    • 2020-11-08
    相关资源
    最近更新 更多