|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + lib, |
| 4 | + fetchFromGitHub, |
| 5 | + fetchpatch, |
| 6 | + gitUpdater, |
| 7 | + libsForQt5, |
| 8 | + pkg-config, |
| 9 | + qt6Packages, |
| 10 | + rtaudio_6, |
| 11 | + rtmidi, |
| 12 | + withQt6 ? false, |
| 13 | +}: |
| 14 | + |
| 15 | +let |
| 16 | + qtPackages = if withQt6 then qt6Packages else libsForQt5; |
| 17 | +in |
| 18 | +stdenv.mkDerivation (finalAttrs: { |
| 19 | + pname = "bambootracker" + lib.optionalString withQt6 "-qt6"; |
| 20 | + version = "0.6.5"; |
| 21 | + |
| 22 | + src = fetchFromGitHub { |
| 23 | + owner = "BambooTracker"; |
| 24 | + repo = "BambooTracker"; |
| 25 | + tag = "v${finalAttrs.version}"; |
| 26 | + fetchSubmodules = true; |
| 27 | + hash = "sha256-WoyOqInOOOIEwsMOc2yoTdh9UhJOvFKE1GfkxOuXDe0="; |
| 28 | + }; |
| 29 | + |
| 30 | + patches = [ |
| 31 | + # Remove when version > 0.6.5 |
| 32 | + (fetchpatch { |
| 33 | + name = "0001-bambootracker-Fix-compiler-warnings.patch"; |
| 34 | + url = "https://github.com/BambooTracker/BambooTracker/commit/d670cf8b6113318cd938cf19be76b6b14d3635f1.patch"; |
| 35 | + hash = "sha256-yyOMaOYKSc1hbbCL7wjFNPDmX2oMYo10J4hjZJss2zs="; |
| 36 | + }) |
| 37 | + |
| 38 | + # Remove when version > 0.6.5 |
| 39 | + (fetchpatch { |
| 40 | + name = "0002-bambootracker-Fix-GCC15-compat.patch"; |
| 41 | + url = "https://github.com/BambooTracker/BambooTracker/commit/92c0a7d1cfb05d1c6ae9482181c5c378082b772c.patch"; |
| 42 | + hash = "sha256-6K0RZD0LevggxFr92LaNmq+eMgOFJgFX60IgAw7tYdM="; |
| 43 | + }) |
| 44 | + |
| 45 | + # Remove when version > 0.6.5 |
| 46 | + (fetchpatch { |
| 47 | + name = "0003-bambootracker-Drop-unused-property.patch"; |
| 48 | + url = "https://github.com/BambooTracker/BambooTracker/commit/de4459f0315f099d3e0a2d20b938ec76285f2d46.patch"; |
| 49 | + hash = "sha256-zTh6i+hgQZ3kEid0IzQaR/PsrYlnhplccdlaS5g8FeA="; |
| 50 | + }) |
| 51 | + ]; |
| 52 | + |
| 53 | + postPatch = lib.optionalString withQt6 '' |
| 54 | + # Work around lrelease finding in qmake being broken by using pre-Qt5.12 code path |
| 55 | + # https://github.com/NixOS/nixpkgs/issues/214765 |
| 56 | + substituteInPlace BambooTracker/lang/lang.pri \ |
| 57 | + --replace 'equals(QT_MAJOR_VERSION, 5):lessThan(QT_MINOR_VERSION, 12)' 'if(true)' |
| 58 | + ''; |
| 59 | + |
| 60 | + nativeBuildInputs = |
| 61 | + [ |
| 62 | + pkg-config |
| 63 | + ] |
| 64 | + ++ (with qtPackages; [ |
| 65 | + qmake |
| 66 | + qttools |
| 67 | + wrapQtAppsHook |
| 68 | + ]); |
| 69 | + |
| 70 | + buildInputs = |
| 71 | + [ |
| 72 | + rtaudio_6 |
| 73 | + rtmidi |
| 74 | + ] |
| 75 | + ++ ( |
| 76 | + with qtPackages; |
| 77 | + [ |
| 78 | + qtbase |
| 79 | + ] |
| 80 | + ++ lib.optionals stdenv.hostPlatform.isLinux [ |
| 81 | + qtwayland |
| 82 | + ] |
| 83 | + ++ lib.optionals withQt6 [ |
| 84 | + qt5compat |
| 85 | + ] |
| 86 | + ); |
| 87 | + |
| 88 | + qmakeFlags = |
| 89 | + [ |
| 90 | + "CONFIG+=system_rtaudio" |
| 91 | + "CONFIG+=system_rtmidi" |
| 92 | + ] |
| 93 | + ++ lib.optionals stdenv.cc.isClang [ |
| 94 | + # Clang is extra-strict about some deprecations |
| 95 | + # https://github.com/BambooTracker/BambooTracker/issues/506 |
| 96 | + "CONFIG+=no_warnings_are_errors" |
| 97 | + ]; |
| 98 | + |
| 99 | + postConfigure = "make qmake_all"; |
| 100 | + |
| 101 | + # Wrapping the inside of the app bundles, avoiding double-wrapping |
| 102 | + dontWrapQtApps = stdenv.hostPlatform.isDarwin; |
| 103 | + |
| 104 | + postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' |
| 105 | + mkdir -p $out/Applications |
| 106 | + mv $out/{bin,Applications}/BambooTracker.app |
| 107 | + ln -s $out/{Applications/BambooTracker.app/Contents/MacOS,bin}/BambooTracker |
| 108 | + wrapQtApp $out/Applications/BambooTracker.app/Contents/MacOS/BambooTracker |
| 109 | + ''; |
| 110 | + |
| 111 | + passthru = { |
| 112 | + updateScript = gitUpdater { |
| 113 | + rev-prefix = "v"; |
| 114 | + }; |
| 115 | + }; |
| 116 | + |
| 117 | + meta = { |
| 118 | + description = "Tracker for YM2608 (OPNA) which was used in NEC PC-8801/9801 series computers"; |
| 119 | + mainProgram = "BambooTracker"; |
| 120 | + homepage = "https://bambootracker.github.io/BambooTracker/"; |
| 121 | + license = lib.licenses.gpl2Plus; |
| 122 | + platforms = lib.platforms.all; |
| 123 | + maintainers = with lib.maintainers; [ OPNA2608 ]; |
| 124 | + }; |
| 125 | +}) |
0 commit comments