{ stdenv, fetchtorrent, fetchurl, alsa-lib, atk, cairo, dpkg, ffmpeg, freetype, gdk-pixbuf, glib, gtk3, harfbuzz, inputs, lib, libglvnd, libjack2, libjpeg, libnghttp2, libxkbcommon, makeWrapper, pango, pipewire, pulseaudio, vulkan-loader, wrapGAppsHook3, xcb-imdkit, xdg-utils, xorg, zlib, zulu, }: stdenv.mkDerivation rec { pname = "bitwig-studio"; version = "5.2.0"; torrent = fetchtorrent { url = "magnet:?xt=urn:btih:A0B9F36BAB2BE31E90DDBBC3A868754D85D1CA55&dn=Bitwig+Studio+5.2.0+Music+Production+DAW+-LiNUX&tr=udp%3A%2F%2Ftracker.opentrackr.org%3A1337%2Fannounce&tr=udp%3A%2F%2Fopen.tracker.cl%3A1337%2Fannounce&tr=udp%3A%2F%2Fopen.demonii.com%3A1337%2Fannounce&tr=udp%3A%2F%2Fopen.stealth.si%3A80%2Fannounce&tr=udp%3A%2F%2Ftracker.torrent.eu.org%3A451%2Fannounce&tr=udp%3A%2F%2Fexodus.desync.com%3A6969%2Fannounce&tr=udp%3A%2F%2Fopen.dstud.io%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker.ololosh.space%3A6969%2Fannounce&tr=udp%3A%2F%2Fexplodie.org%3A6969%2Fannounce&tr=udp%3A%2F%2Ftracker-udp.gbitt.info%3A80%2Fannounce"; hash = "sha256-cOjYVF5GpWAFu2OjxHAhEfcjN8UFlhp76yS6ajNgZWQ="; backend = "transmission"; }; themeEditor = fetchurl { url = "https://github.com/Berikai/bitwig-theme-editor/releases/download/1.4.3/bitwig-theme-editor-1.4.3.jar"; hash = "sha256-TvYvPPjT/qlYFxgGyxEaDXrjNtaWfppFqgArjSQuunw="; }; theme = ""; src = "${torrent}/bitwig-studio-5.2.deb"; patch = "${torrent}/FLARE/bitwig.jar"; nativeBuildInputs = [ dpkg makeWrapper wrapGAppsHook3 zulu ]; dontBuild = true; dontWrapGApps = true; # we only want $gappsWrapperArgs here buildInputs = with xorg; [ alsa-lib atk cairo freetype gdk-pixbuf glib gtk3 harfbuzz libglvnd libjack2 # libjpeg8 is required for converting jpeg's to colour palettes libjpeg libnghttp2 libxcb libXcursor libX11 libXtst libxkbcommon pango pipewire pulseaudio (lib.getLib stdenv.cc.cc) vulkan-loader xcb-imdkit xcbutil xcbutilwm zlib ]; installPhase = '' runHook preInstall mkdir -p $out/bin cp -r opt/bitwig-studio $out/libexec # Check if a theme has been provided if [[ -z $theme ]]; then java -jar $themeEditor $patch apply $theme fi # haxx :^) cp $patch $out/libexec/bin/bitwig.jar ln -s $out/libexec/bitwig-studio $out/bin/bitwig-studio cp -r usr/share $out/share # Bitwig includes a copy of libxcb-imdkit. # Removing it will force it to use our version. rm $out/libexec/lib/bitwig-studio/libxcb-imdkit.so.1 substitute usr/share/applications/com.bitwig.BitwigStudio.desktop \ $out/share/applications/com.bitwig.BitwigStudio.desktop \ --replace /usr/bin/bitwig-studio $out/bin/bitwig-studio runHook postInstall ''; postFixup = '' # patchelf fails to set rpath on BitwigStudioEngine, so we use # the LD_LIBRARY_PATH way find $out -type f -executable \ -not -name '*.so.*' \ -not -name '*.so' \ -not -name '*.jar' \ -not -name 'jspawnhelper' \ -not -path '*/resources/*' | \ while IFS= read -r f ; do patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f # make xdg-open overrideable at runtime wrapProgram $f \ "''${gappsWrapperArgs[@]}" \ --prefix PATH : "${lib.makeBinPath [ ffmpeg ]}" \ --suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \ --suffix LD_LIBRARY_PATH : "${lib.strings.makeLibraryPath buildInputs}" done find $out -type f -executable -name 'jspawnhelper' | \ while IFS= read -r f ; do patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f done ''; meta = with lib; { description = "Digital audio workstation"; longDescription = '' Bitwig Studio is a multi-platform music-creation system for production, performance and DJing, with a focus on flexible editing tools and a super-fast workflow. ''; homepage = "https://www.bitwig.com/"; license = licenses.unfree; platforms = [ "x86_64-linux" ]; maintainers = with maintainers; [ bfortz michalrus mrVanDalo wiredsis ]; sourceProvenance = [ lib.sourceTypes.binaryNativeCode ]; }; }