about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/wildmidi/default.nix
blob: 23dc8dc3b05302210524c19269fdf5f3ebd92823 (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
{ lib, stdenv, fetchFromGitHub, writeTextFile, cmake, alsa-lib, OpenAL, freepats }:

let
  defaultCfgPath = "${placeholder "out"}/etc/wildmidi/wildmidi.cfg";
in
stdenv.mkDerivation rec {
  pname = "wildmidi";
  version = "0.4.5";

  src = fetchFromGitHub {
    owner = "Mindwerks";
    repo = "wildmidi";
    rev = "${pname}-${version}";
    sha256 = "sha256-5El8aDpAgjrW0/4lphZEF+Hfv9Xr7J4DMk1b/Tb+0TU=";
  };

  nativeBuildInputs = [ cmake ];

  buildInputs = lib.optionals stdenv.buildPlatform.isLinux [
    alsa-lib stdenv.cc.libc/*couldn't find libm*/
  ] ++ lib.optionals stdenv.buildPlatform.isDarwin [
    OpenAL
  ];

  preConfigure = ''
    # https://github.com/Mindwerks/wildmidi/issues/236
    substituteInPlace src/wildmidi.pc.in \
      --replace '$'{exec_prefix}/@CMAKE_INSTALL_LIBDIR@ @CMAKE_INSTALL_FULL_LIBDIR@ \
      --replace '$'{exec_prefix}/@CMAKE_INSTALL_INCLUDEDIR@ @CMAKE_INSTALL_FULL_INCLUDEDIR@
  '';

  cmakeFlags = [
    "-DWILDMIDI_CFG=${defaultCfgPath}"
  ];

  postInstall = let
    defaultCfg = writeTextFile {
      name = "wildmidi.cfg";
      text = ''
        dir ${freepats}
        source ${freepats}/freepats.cfg
      '';
    };
  in ''
    mkdir -p "$(dirname ${defaultCfgPath})"
    ln -s ${defaultCfg} ${defaultCfgPath}
  '';

  meta = with lib; {
    description = "Software MIDI player and library";
    longDescription = ''
      WildMIDI is a simple software midi player which has a core softsynth
      library that can be use with other applications.
    '';
    homepage = "https://wildmidi.sourceforge.net/";
    # The library is LGPLv3, the wildmidi executable is GPLv3
    license = licenses.lgpl3;
    platforms = platforms.unix;
    maintainers = [ maintainers.bjornfor ];
  };
}