summary refs log tree commit diff
path: root/pkgs/applications/audio/midisheetmusic/default.nix
blob: 388fc2a1b3ea11f8020b634778894fc2a6d29776 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
{ stdenv, fetchurl
, mono, dotnetPackages, makeWrapper
, gtk2, cups, timidity }:

let
  version = "2.6";
in stdenv.mkDerivation {
  pname = "midisheetmusic";
  inherit version;

  src = fetchurl {
    url = "mirror://sourceforge/midisheetmusic/MidiSheetMusic-${version}-linux-src.tar.gz";
    sha256 = "05c6zskj50g29f51lx8fvgzsi3f31z01zj6ssjjrgr7jfs7ak70p";
  };

  checkInputs = (with dotnetPackages; [ NUnitConsole ]);
  nativeBuildInputs = [ mono makeWrapper ];

  buildPhase = ''
    for i in Classes/MidiPlayer.cs Classes/MidiSheetMusic.cs
    do
      substituteInPlace $i --replace "/usr/bin/timidity" "${timidity}/bin/timidity"
    done

    ./build.sh
  '';

  # include missing file with unit tests for building
  # switch from mono nunit dll to standalone dll otherwise mono compiler barks
  # run via nunit3 console, because mono nunit console wants access $HOME
  checkPhase = ''
    substituteInPlace UnitTestDLL.csproj \
      --replace "</Compile>" '</Compile><Compile Include="Classes\UnitTest.cs"/>' \
      --replace nunit.framework.dll "${dotnetPackages.NUnit}/lib/dotnet/NUnit/nunit.framework.dll"
    ./build_unit_test.sh
    nunit3-console bin/Debug/UnitTest.dll
  '';

  # 2 tests of 47 are still failing
  doCheck = false;

  installPhase = ''
    mkdir -p $out/share/applications $out/share/pixmaps $out/bin

    cp deb/midisheetmusic.desktop $out/share/applications
    cp NotePair.png $out/share/pixmaps/midisheetmusic.png
    cp bin/Debug/MidiSheetMusic.exe $out/bin/.MidiSheetMusic.exe

    makeWrapper ${mono}/bin/mono $out/bin/midisheetmusic.mono.exe \
      --prefix LD_LIBRARY_PATH : ${stdenv.lib.makeLibraryPath [ gtk2 cups ]} \
      --prefix PATH : ${stdenv.lib.makeBinPath [ timidity ]} \
      --add-flags $out/bin/.MidiSheetMusic.exe
  '';

  meta = with stdenv.lib; {
    description = "Convert MIDI Files to Piano Sheet Music for two hands";
    homepage = "http://midisheetmusic.com";
    license = licenses.gpl2;
    maintainers = [ maintainers.gnidorah ];
    platforms = platforms.linux;
  };
}