skrooge: 2.31.0 -> 2.33.0 (#365685)
[NixPkgs.git] / pkgs / by-name / vc / vcv-rack / package.nix
blob16ec47c31c5d0976a6a196d27ab2d8707af47583
2   alsa-lib,
3   cmake,
4   copyDesktopItems,
5   curl,
6   fetchFromBitbucket,
7   fetchFromGitHub,
8   ghc_filesystem,
9   glew,
10   glfw,
11   zenity,
12   gtk3-x11,
13   imagemagick,
14   jansson,
15   jq,
16   lib,
17   libarchive,
18   libicns,
19   libjack2,
20   libpulseaudio,
21   libsamplerate,
22   makeDesktopItem,
23   makeWrapper,
24   pkg-config,
25   rtmidi,
26   speexdsp,
27   stdenv,
28   wrapGAppsHook3,
29   zstd,
32 let
33   # The package repo vendors some of the package dependencies as submodules.
34   # Unfortunately, they are not pinned, so we have no guarantee that they
35   # will be stable, and therefore, we can't use them directly. Instead
36   # we'll have to fetch them separately ourselves.
37   pffft-source = fetchFromBitbucket {
38     owner = "jpommier";
39     repo = "pffft";
40     rev = "fbc4058602803f40dc554b8a5d2bcc694c005f2f";
41     sha256 = "16biji3115232cr1j975hpxw68lfybajlspnhfjcwg8jz2d8ybrf";
42   };
43   fuzzysearchdatabase-source = fetchFromBitbucket {
44     owner = "j_norberg";
45     repo = "fuzzysearchdatabase";
46     rev = "23122d1ff60d936fd766361a30210c954e0c5449";
47     sha256 = "1s88blx1rn2racmb8n5g0kh1ym7v21573l5m42c4nz266vmrvrvz";
48   };
49   nanovg-source = fetchFromGitHub {
50     owner = "VCVRack";
51     repo = "nanovg";
52     rev = "0bebdb314aff9cfa28fde4744bcb037a2b3fd756";
53     sha256 = "HmQhCE/zIKc3f+Zld229s5i5MWzRrBMF9gYrn8JVQzg=";
54   };
55   nanosvg-source = fetchFromGitHub {
56     owner = "memononen";
57     repo = "nanosvg";
58     rev = "9da543e8329fdd81b64eb48742d8ccb09377aed1";
59     sha256 = "1pkzv75kavkhrbdd2kvq755jyr0vamgrfr7lc33dq3ipkzmqvs2l";
60   };
61   osdialog-source = fetchFromGitHub {
62     owner = "AndrewBelt";
63     repo = "osdialog";
64     rev = "d0f64f0798c2e47f61d90a5505910ff2d63ca049";
65     sha256 = "1d3058x6wgzw7b0wai792flk7s6ffw0z4n9sl016v91yjwv7ds3a";
66   };
67   oui-blendish-source = fetchFromGitHub {
68     owner = "VCVRack";
69     repo = "oui-blendish";
70     rev = "2fc6405883f8451944ed080547d073c8f9f31898";
71     sha256 = "1bs0654312555vm7nzswsmky4l8759bjdk17pl22p49rw9k4a1px";
72   };
73   simde-source = fetchFromGitHub {
74     owner = "simd-everywhere";
75     repo = "simde";
76     rev = "416091ebdb9e901b29d026633e73167d6353a0b0";
77     sha256 = "064ygc6c737yjx04rydwwhkr4n4s4rbvj27swxwyzvp1h8nka6xf";
78   };
79   tinyexpr-source = fetchFromGitHub {
80     owner = "codeplea";
81     repo = "tinyexpr";
82     rev = "9907207e5def0fabdb60c443517b0d9e9d521393";
83     sha256 = "0xbpd09zvrk2ppm1qm1skk6p50mqr9mzjixv3s0biqq6jpabs88l";
84   };
85   fundamental-source = fetchFromGitHub {
86     owner = "VCVRack";
87     repo = "Fundamental";
88     rev = "5ed79544161e0fa9a55faa7c0a5f299e828e12ab"; # tip of branch v2
89     sha256 = "0c6qpigyr0ppvra20hcy1fdcmqa212jckb9wkx4f6fgdby7565wv";
90   };
91   vcv-rtaudio = stdenv.mkDerivation rec {
92     pname = "vcv-rtaudio";
93     version = "unstable-2020-01-30";
95     src = fetchFromGitHub {
96       owner = "VCVRack";
97       repo = "rtaudio";
98       rev = "ece277bd839603648c80c8a5f145678e13bc23f3"; # tip of master branch
99       sha256 = "11gpl0ak757ilrq4fi0brj0chmlcr1hihc32yd7qza4fxjw2yx2v";
100     };
102     nativeBuildInputs = [
103       cmake
104       pkg-config
105     ];
107     buildInputs = [
108       alsa-lib
109       libjack2
110       libpulseaudio
111     ];
113     cmakeFlags = [
114       "-DRTAUDIO_API_ALSA=ON"
115       "-DRTAUDIO_API_PULSE=ON"
116       "-DRTAUDIO_API_JACK=ON"
117       "-DRTAUDIO_API_CORE=OFF"
118     ];
119   };
121 stdenv.mkDerivation rec {
122   pname = "vcv-rack";
123   version = "2.5.1";
125   desktopItems = [
126     (makeDesktopItem {
127       type = "Application";
128       name = pname;
129       desktopName = "VCV Rack";
130       genericName = "Eurorack simulator";
131       comment = "Create music by patching together virtual synthesizer modules";
132       exec = "Rack";
133       icon = "Rack";
134       categories = [
135         "AudioVideo"
136         "AudioVideoEditing"
137         "Audio"
138       ];
139       keywords = [ "music" ];
140     })
141   ];
143   src = fetchFromGitHub {
144     owner = "VCVRack";
145     repo = "Rack";
146     rev = "v${version}";
147     sha256 = "1q2bwjfn6crk9lyd6m3py0v754arw1xgpv5kkj6ka1bc2yz839qh";
148   };
150   patches = [
151     ./rack-minimize-vendoring.patch
152   ];
154   prePatch = ''
155     # As we can't use `make dep` to set up the dependencies (as explained
156     # above), we do it here manually
157     mkdir -p dep/include
159     cp -r ${pffft-source}/* dep/pffft
160     cp -r ${fuzzysearchdatabase-source}/* dep/fuzzysearchdatabase
161     cp -r ${nanovg-source}/* dep/nanovg
162     cp -r ${nanosvg-source}/* dep/nanosvg
163     cp -r ${osdialog-source}/* dep/osdialog
164     cp -r ${oui-blendish-source}/* dep/oui-blendish
165     cp -r ${simde-source}/* dep/simde
166     cp -r ${tinyexpr-source}/* dep/tinyexpr
168     cp dep/pffft/*.h dep/include
169     cp dep/fuzzysearchdatabase/src/*.hpp dep/include
170     cp dep/nanosvg/**/*.h dep/include
171     cp dep/nanovg/src/*.h dep/include
172     cp dep/osdialog/*.h dep/include
173     cp dep/oui-blendish/*.h dep/include
174     cp -r dep/simde/simde dep/include
175     cp dep/tinyexpr/tinyexpr.h dep/include
177     # Build and dist the Fundamental plugins
178     cp -r ${fundamental-source} plugins/Fundamental/
179     chmod -R +rw plugins/Fundamental # will be used as build dir
180     substituteInPlace plugin.mk --replace ":= all" ":= dist"
181     substituteInPlace plugins/Fundamental/src/Logic.cpp \
182       --replace \
183         "LightButton<VCVBezelBig, VCVBezelLightBig<WhiteLight>>" \
184         "struct rack::componentlibrary::LightButton<VCVBezelBig, VCVBezelLightBig<WhiteLight>>"
186     # Fix reference to zenity
187     substituteInPlace dep/osdialog/osdialog_zenity.c \
188       --replace 'zenityBin[] = "zenity"' 'zenityBin[] = "${zenity}/bin/zenity"'
189   '';
191   nativeBuildInputs = [
192     copyDesktopItems
193     imagemagick
194     jq
195     libicns
196     makeWrapper
197     pkg-config
198     wrapGAppsHook3
199   ];
200   buildInputs = [
201     alsa-lib
202     curl
203     ghc_filesystem
204     glew
205     glfw
206     zenity
207     gtk3-x11
208     jansson
209     libarchive
210     libjack2
211     libpulseaudio
212     libsamplerate
213     rtmidi
214     speexdsp
215     vcv-rtaudio
216     zstd
217   ];
219   makeFlags =
220     lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
221       "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
222     ]
223     ++ [
224       "all"
225       "plugins"
226     ];
228   installPhase = ''
229     runHook preInstall
231     install -D -m755 -t $out/bin Rack
232     install -D -m755 -t $out/lib libRack.so
234     mkdir -p $out/share/vcv-rack
235     cp -r res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt $out/share/vcv-rack
236     cp -r plugins/Fundamental/dist/Fundamental-*.vcvplugin $out/share/vcv-rack/Fundamental.vcvplugin
238     # Extract pngs from the Apple icon image and create
239     # the missing ones from the 1024x1024 image.
240     icns2png --extract icon.icns
241     for size in 16 24 32 48 64 128 256 512 1024; do
242       mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps
243       if [ ! -e icon_"$size"x"$size"x32.png ] ; then
244         convert -resize "$size"x"$size" icon_1024x1024x32.png icon_"$size"x"$size"x32.png
245       fi
246       install -Dm644 icon_"$size"x"$size"x32.png $out/share/icons/hicolor/"$size"x"$size"/apps/Rack.png
247     done;
249     runHook postInstall
250   '';
252   dontWrapGApps = true;
253   postFixup = ''
254     # Wrap gApp and override the default global resource file directory
255     wrapProgram $out/bin/Rack \
256         "''${gappsWrapperArgs[@]}" \
257         --add-flags "-s $out/share/vcv-rack"
258   '';
260   meta = with lib; {
261     description = "Open-source virtual modular synthesizer";
262     homepage = "https://vcvrack.com/";
263     # The source is GPL3+ licensed, some of the art is CC-BY-NC 4.0 or under a
264     # no-derivatives clause
265     license = with licenses; [
266       gpl3Plus
267       cc-by-nc-40
268       unfreeRedistributable
269     ];
270     maintainers = with maintainers; [
271       nathyong
272       jpotier
273       ddelabru
274     ];
275     mainProgram = "Rack";
276     platforms = platforms.linux;
277   };