about summary refs log tree commit diff
path: root/nixpkgs/pkgs/tools/audio/opl3bankeditor/common.nix
blob: 04f4d3aae5ab566409f13734d46267fda4164a41 (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
63
64
65
66
67
68
{ pname, chip, version, sha256, extraPatches ? [] }:

{ mkDerivation
, stdenv
, lib
, fetchFromGitHub
, dos2unix
, cmake
, pkg-config
, qttools
, qtbase
, qwt
, rtaudio
, rtmidi
}:

let
  binname = "${chip} Bank Editor";
  mainProgram = "${lib.strings.toLower chip}_bank_editor";
in
mkDerivation rec {
  inherit pname version;

  src = fetchFromGitHub {
    owner = "Wohlstand";
    repo = pname;
    rev = "v${version}";
    inherit sha256;
  };

  prePatch = ''
    dos2unix CMakeLists.txt
  '';

  patches = extraPatches;

  nativeBuildInputs = [
    dos2unix
    cmake
    pkg-config
    qttools
  ];

  buildInputs = [
    qtbase
    qwt
    rtaudio
    rtmidi
  ];

  postInstall = lib.optionalString stdenv.hostPlatform.isDarwin ''
    mkdir $out/{bin,Applications}
    mv "${binname}.app" $out/Applications/

    install_name_tool -change {,${qwt}/lib/}libqwt.6.dylib "$out/Applications/${binname}.app/Contents/MacOS/${binname}"

    ln -s "$out/Applications/${binname}.app/Contents/MacOS/${binname}" $out/bin/${mainProgram}
  '';

  meta = with lib; {
    inherit mainProgram;
    description = "A small cross-platform editor of the ${chip} FM banks of different formats";
    homepage = src.meta.homepage;
    license = licenses.gpl3Plus;
    platforms = platforms.all;
    maintainers = with maintainers; [ OPNA2608 ];
  };
}