Installation of Haskell Package Euterpea fails on NixOs

392 views Asked by At

Unfortunately, the installation of the haskell package 'Euterpea' fails on NixOS:

The Nixpkgs manual states that all haskell packages registered on hackage (which the Euterpea package is) are included in the nix package manager and have to be installed like this:

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

After some downloading and compiling, the following error occurs, and the process is interrupted:

[ 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

Does anyone have an idea how to fix this?

1

There are 1 answers

0
bennofs On

The problem here is that Euterpea does not compile against the more-recent versions of its dependencies available in nixpkgs. Here is an expression that can succcessfully build Euterpea (tested on current nixpkgs unstable):

Write the following nix expression into a file called 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;
}

Then you can run the following commands:

$ 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
$