1{
2 stdenv,
3 fetchurl,
4 alsa-lib,
5 atk,
6 cairo,
7 dpkg,
8 ffmpeg,
9 freetype,
10 gdk-pixbuf,
11 glib,
12 gtk3,
13 harfbuzz,
14 lcms,
15 lib,
16 libglvnd,
17 libjack2,
18 libjpeg,
19 libnghttp2,
20 libudev-zero,
21 libxkbcommon,
22 makeWrapper,
23 pango,
24 pipewire,
25 vulkan-loader,
26 wrapGAppsHook3,
27 xcb-imdkit,
28 xdg-utils,
29 xorg,
30 zlib,
31}:
32
33stdenv.mkDerivation rec {
34 pname = "bitwig-studio-unwrapped";
35 version = "5.3.11";
36
37 src = fetchurl {
38 name = "bitwig-studio-${version}.deb";
39 url = "https://www.bitwig.com/dl/Bitwig%20Studio/${version}/installer_linux/";
40 hash = "sha256-8u8ljljHKGV6m2421vxYSiDTb1iyNLgP3DlLIEKuzXo=";
41 };
42
43 nativeBuildInputs = [
44 dpkg
45 makeWrapper
46 wrapGAppsHook3
47 ];
48
49 dontBuild = true;
50 dontWrapGApps = true; # we only want $gappsWrapperArgs here
51
52 buildInputs = [
53 alsa-lib
54 atk
55 cairo
56 freetype
57 gdk-pixbuf
58 glib
59 gtk3
60 harfbuzz
61 lcms
62 libglvnd
63 libjack2
64 # libjpeg8 is required for converting jpeg's to colour palettes
65 libjpeg
66 libnghttp2
67 xorg.libxcb
68 xorg.libXcursor
69 xorg.libX11
70 xorg.libXtst
71 libxkbcommon
72 libudev-zero
73 pango
74 pipewire
75 (lib.getLib stdenv.cc.cc)
76 vulkan-loader
77 xcb-imdkit
78 xorg.xcbutil
79 xorg.xcbutilwm
80 zlib
81 ];
82
83 installPhase = ''
84 runHook preInstall
85
86 mkdir -p $out/bin
87 cp -r opt/bitwig-studio $out/libexec
88 ln -s $out/libexec/bitwig-studio $out/bin/bitwig-studio
89 cp -r usr/share $out/share
90
91 # Bitwig includes a copy of libxcb-imdkit.
92 # Removing it will force it to use our version.
93 rm $out/libexec/lib/bitwig-studio/libxcb-imdkit.so.1
94
95 substitute usr/share/applications/com.bitwig.BitwigStudio.desktop \
96 $out/share/applications/com.bitwig.BitwigStudio.desktop \
97 --replace /usr/bin/bitwig-studio $out/bin/bitwig-studio
98
99 runHook postInstall
100 '';
101
102 postFixup = ''
103 # patchelf fails to set rpath on BitwigStudioEngine, so we use
104 # the LD_LIBRARY_PATH way
105
106 find $out -type f -executable \
107 -not -name '*.so.*' \
108 -not -name '*.so' \
109 -not -name '*.jar' \
110 -not -name 'jspawnhelper' \
111 -not -path '*/resources/*' | \
112 while IFS= read -r f ; do
113 patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f
114 # make xdg-open overrideable at runtime
115 wrapProgram $f \
116 "''${gappsWrapperArgs[@]}" \
117 --prefix PATH : "${lib.makeBinPath [ ffmpeg ]}" \
118 --suffix PATH : "${lib.makeBinPath [ xdg-utils ]}" \
119 --suffix LD_LIBRARY_PATH : "${lib.strings.makeLibraryPath buildInputs}"
120 done
121
122 find $out -type f -executable -name 'jspawnhelper' | \
123 while IFS= read -r f ; do
124 patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $f
125 done
126 '';
127
128 meta = {
129 description = "Digital audio workstation";
130 longDescription = ''
131 Bitwig Studio is a multi-platform music-creation system for
132 production, performance and DJing, with a focus on flexible
133 editing tools and a super-fast workflow.
134 '';
135 homepage = "https://www.bitwig.com/";
136 license = lib.licenses.unfree;
137 platforms = [ "x86_64-linux" ];
138 maintainers = with lib.maintainers; [
139 bfortz
140 michalrus
141 mrVanDalo
142 ];
143 sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
144 };
145}