diff --git a/pkgs/by-name/vc/vcv-rack/package.nix b/pkgs/by-name/vc/vcv-rack/package.nix index da20022db086f..337995abe01ee 100644 --- a/pkgs/by-name/vc/vcv-rack/package.nix +++ b/pkgs/by-name/vc/vcv-rack/package.nix @@ -1,10 +1,12 @@ { alsa-lib, + apple-sdk_13, cmake, copyDesktopItems, curl, fetchFromBitbucket, fetchFromGitHub, + fetchpatch, ghc_filesystem, glew, glfw, @@ -21,8 +23,10 @@ libsamplerate, makeDesktopItem, makeWrapper, + openssl, pkg-config, rtmidi, + rsync, speexdsp, stdenv, wrapGAppsHook3, @@ -34,69 +38,76 @@ let # Unfortunately, they are not pinned, so we have no guarantee that they # will be stable, and therefore, we can't use them directly. Instead # we'll have to fetch them separately ourselves. - pffft-source = fetchFromBitbucket { - owner = "jpommier"; - repo = "pffft"; - rev = "fbc4058602803f40dc554b8a5d2bcc694c005f2f"; - sha256 = "16biji3115232cr1j975hpxw68lfybajlspnhfjcwg8jz2d8ybrf"; + # The revs used here have been determined using git submodule status. + filesystem-source = fetchFromGitHub { + owner = "gulrak"; + repo = "filesystem"; + rev = "7e37433f318488ae4bc80f80e12df12a01579874"; + hash = "sha256-dHwNsuuFkhd9Y24KRzGV9Z9UZolNtOtxyA1AEVG7uMU="; }; fuzzysearchdatabase-source = fetchFromBitbucket { owner = "j_norberg"; repo = "fuzzysearchdatabase"; rev = "23122d1ff60d936fd766361a30210c954e0c5449"; - sha256 = "1s88blx1rn2racmb8n5g0kh1ym7v21573l5m42c4nz266vmrvrvz"; + hash = "sha256-f+ed6zZGfEuYILXQcUoQ+1Qf4ASvWLQqU1nYHDpdCOk="; + }; + nanosvg-source = fetchFromGitHub { + owner = "memononen"; + repo = "nanosvg"; + rev = "25241c5a8f8451d41ab1b02ab2d865b01600d949"; + hash = "sha256-b/aBmvuvKScF8zSkyF1tuqL9hov4XVLzKLTpr6p7mIQ="; }; nanovg-source = fetchFromGitHub { owner = "VCVRack"; repo = "nanovg"; rev = "0bebdb314aff9cfa28fde4744bcb037a2b3fd756"; - sha256 = "HmQhCE/zIKc3f+Zld229s5i5MWzRrBMF9gYrn8JVQzg="; - }; - nanosvg-source = fetchFromGitHub { - owner = "memononen"; - repo = "nanosvg"; - rev = "9da543e8329fdd81b64eb48742d8ccb09377aed1"; - sha256 = "1pkzv75kavkhrbdd2kvq755jyr0vamgrfr7lc33dq3ipkzmqvs2l"; + hash = "sha256-HmQhCE/zIKc3f+Zld229s5i5MWzRrBMF9gYrn8JVQzg="; }; osdialog-source = fetchFromGitHub { owner = "AndrewBelt"; repo = "osdialog"; - rev = "d0f64f0798c2e47f61d90a5505910ff2d63ca049"; - sha256 = "1d3058x6wgzw7b0wai792flk7s6ffw0z4n9sl016v91yjwv7ds3a"; + rev = "64482bde25a8e19cc38342ed21aa0e38c2751f6c"; + hash = "sha256-FiejDeZkLoyS7BBwPYBfdOCLxBV8hAFzJAFeTz80tH0="; }; oui-blendish-source = fetchFromGitHub { owner = "VCVRack"; repo = "oui-blendish"; rev = "2fc6405883f8451944ed080547d073c8f9f31898"; - sha256 = "1bs0654312555vm7nzswsmky4l8759bjdk17pl22p49rw9k4a1px"; + hash = "sha256-/QZFZuI5kSsEvSfMJlcqB1HiZ9Vcf3vqLqWIMEgxQK8="; + }; + pffft-source = fetchFromBitbucket { + owner = "jpommier"; + repo = "pffft"; + rev = "74d7261be17cf659d5930d4830609406bd7553e3"; + hash = "sha256-gYaumUeXYf3axAexGqWI/tYBs1dyebjAESo4o/DTjCA="; }; simde-source = fetchFromGitHub { owner = "simd-everywhere"; repo = "simde"; - rev = "416091ebdb9e901b29d026633e73167d6353a0b0"; - sha256 = "064ygc6c737yjx04rydwwhkr4n4s4rbvj27swxwyzvp1h8nka6xf"; + rev = "dd0b662fd8cf4b1617dbbb4d08aa053e512b08e4"; + hash = "sha256-21YBpP7jwFqNiOu5Ilu8t9nt+AZmLc3PVEwHAWn7vM8="; }; tinyexpr-source = fetchFromGitHub { owner = "codeplea"; repo = "tinyexpr"; - rev = "9907207e5def0fabdb60c443517b0d9e9d521393"; - sha256 = "0xbpd09zvrk2ppm1qm1skk6p50mqr9mzjixv3s0biqq6jpabs88l"; + rev = "4e8cc0067a1e2378faae23eb2dfdd21e9e9907c2"; + hash = "sha256-jYC0kSmYdzJsEaH9gres/NOcfsh+2ymqZAGxNbjus/s="; }; fundamental-source = fetchFromGitHub { owner = "VCVRack"; repo = "Fundamental"; - rev = "5ed79544161e0fa9a55faa7c0a5f299e828e12ab"; # tip of branch v2 - sha256 = "0c6qpigyr0ppvra20hcy1fdcmqa212jckb9wkx4f6fgdby7565wv"; + rev = "v2.6.4"; + hash = "sha256-rpOIMFO17ixgJZDRRg6RdLKorN/XKCUXkapsxN1pmQ4="; }; vcv-rtaudio = stdenv.mkDerivation { pname = "vcv-rtaudio"; - version = "unstable-2020-01-30"; + version = "5.1.0-unstable-2022-11-22"; src = fetchFromGitHub { owner = "VCVRack"; repo = "rtaudio"; - rev = "ece277bd839603648c80c8a5f145678e13bc23f3"; # tip of master branch - sha256 = "11gpl0ak757ilrq4fi0brj0chmlcr1hihc32yd7qza4fxjw2yx2v"; + rev = "22d64cdcb151e388791caceee8aa0011a6aa46e0"; # tip of master branch + hash = "sha256-BW5XwbsuwbbFDHXnQrUMM+1p7Zy7zjwdHHQFGo2XMv0="; }; nativeBuildInputs = [ @@ -105,27 +116,31 @@ let ]; buildInputs = [ + openssl + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ alsa-lib libjack2 libpulseaudio - ]; + ] + ++ lib.optional stdenv.hostPlatform.isDarwin [ apple-sdk_13 ]; cmakeFlags = [ - "-DRTAUDIO_API_ALSA=ON" - "-DRTAUDIO_API_PULSE=ON" - "-DRTAUDIO_API_JACK=ON" - "-DRTAUDIO_API_CORE=OFF" + (lib.cmakeBool "RTAUDIO_API_ALSA" stdenv.hostPlatform.isLinux) + (lib.cmakeBool "RTAUDIO_API_PULSE" stdenv.hostPlatform.isLinux) + (lib.cmakeBool "RTAUDIO_API_JACK" stdenv.hostPlatform.isLinux) + (lib.cmakeBool "RTAUDIO_API_CORE" stdenv.hostPlatform.isDarwin) ]; }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "vcv-rack"; - version = "2.6.0"; + version = "2.6.6"; desktopItems = [ (makeDesktopItem { type = "Application"; - name = pname; + name = "vcv-rack"; desktopName = "VCV Rack"; genericName = "Eurorack simulator"; comment = "Create music by patching together virtual synthesizer modules"; @@ -143,12 +158,22 @@ stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "VCVRack"; repo = "Rack"; - tag = "v${version}"; - hash = "sha256-leI0wwhYiA8qktJFe6DuZjs6q5tMFQ4WFLD4Ivom5+E="; + tag = "v${finalAttrs.version}"; + hash = "sha256-v5/zk1eT5PRB4bwpCdlKb0nr7qERDM9jP5Q78F30O78="; }; patches = [ + # N.B.: Loading modules may fail due to symbols used by the moodules + # not being found, to address this issue the libraries providing the + # symbols are re-exported when building on Darwin using -Wl,-reexport-l. ./rack-minimize-vendoring.patch + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + (fetchpatch { + name = "fix-segfault-on-linux.patch"; + url = "https://github.com/VCVRack/Rack/pull/1944.patch"; + hash = "sha256-dlndyCfCznGDzlWNWrQTgh+FtmsrrL2DVuRE0xCxUck="; + }) ]; prePatch = '' @@ -156,12 +181,13 @@ stdenv.mkDerivation rec { # above), we do it here manually mkdir -p dep/include - cp -r ${pffft-source}/* dep/pffft + cp -r ${filesystem-source}/* dep/filesystem cp -r ${fuzzysearchdatabase-source}/* dep/fuzzysearchdatabase - cp -r ${nanovg-source}/* dep/nanovg cp -r ${nanosvg-source}/* dep/nanosvg + cp -r ${nanovg-source}/* dep/nanovg cp -r ${osdialog-source}/* dep/osdialog cp -r ${oui-blendish-source}/* dep/oui-blendish + cp -r ${pffft-source}/* dep/pffft cp -r ${simde-source}/* dep/simde cp -r ${tinyexpr-source}/* dep/tinyexpr @@ -177,44 +203,83 @@ stdenv.mkDerivation rec { # Build and dist the Fundamental plugins cp -r ${fundamental-source} plugins/Fundamental/ chmod -R +rw plugins/Fundamental # will be used as build dir - substituteInPlace plugin.mk --replace ":= all" ":= dist" + substituteInPlace plugin.mk --replace-fail ":= all" ":= dist" substituteInPlace plugins/Fundamental/src/Logic.cpp \ - --replace \ + --replace-fail \ "LightButton>" \ "struct rack::componentlibrary::LightButton>" - + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' # Fix reference to zenity substituteInPlace dep/osdialog/osdialog_zenity.c \ - --replace 'zenityBin[] = "zenity"' 'zenityBin[] = "${zenity}/bin/zenity"' + --replace-fail 'zenityBin[] = "zenity"' 'zenityBin[] = "${lib.getExe zenity}"' + # For some unknown reason __yield isn't available on aarch64-linux + substituteInPlace src/engine/Engine.cpp \ + --replace-fail '__yield();' 'asm volatile("yield");' + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + # * Set VERSION from finalAttrs to avoid build using git to determine version + # * Darwin needs to build the dist target, which builds the .app container, + # yet we want to exclude the documentation from dist target. + # * Skip stripping the binary to avoid "unsupported load command" error, which + # appears since several libraries are re-exported (see rack-minimize-vendoring.patch) + # * Replace path to Fundamental module with path to produced build artifact + # to avoid downloading a pre-compiled version + substituteInPlace Makefile \ + --replace-fail 'VERSION ?= $' 'VERSION ?= ${finalAttrs.version}#$' \ + --replace-fail 'DIST_HTML :=' '#DIST_HTML :=' \ + --replace-fail '$(STRIP)' '#$(STRIP)' \ + --replace-fail 'FUNDAMENTAL_FILENAME := Fundamental' 'FUNDAMENTAL_FILENAME := plugins/Fundamental/dist/Fundamental' + + # Skip codesigning + substituteInPlace plugin.mk \ + --replace-fail '$(CODESIGN)' '#$(CODESIGN)' + + # To support macOS drag & drop a custom glfw patch is needed + # (see https://github.com/glfw/glfw/pull/1579 for details). + # Since the patch does not apply cleanly on the current glfw contained in nixpkgs + # disable drag & drop functionality for the time being. + substituteInPlace adapters/standalone.cpp \ + --replace-fail 'glfwGetOpenedFilenames()' 'NULL' ''; nativeBuildInputs = [ - copyDesktopItems - imagemagick jq - libicns makeWrapper pkg-config + zstd + ] + ++ lib.optionals stdenv.isLinux [ + copyDesktopItems + imagemagick + libicns wrapGAppsHook3 - ]; + ] + ++ lib.optionals stdenv.isDarwin [ rsync ]; + buildInputs = [ - alsa-lib curl ghc_filesystem glew glfw - zenity - gtk3-x11 jansson libarchive - libjack2 - libpulseaudio libsamplerate rtmidi speexdsp vcv-rtaudio zstd - ]; + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ + alsa-lib + gtk3-x11 + libjack2 + libpulseaudio + zenity + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ apple-sdk_13 ]; + + enableParallelBuilding = true; makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ @@ -225,8 +290,17 @@ stdenv.mkDerivation rec { "plugins" ]; + # To be able to use enableParallelBuilding = true + # the dist target needs run after the buildPhase as + # it depends on the all and plugin targets. + postBuild = lib.optionalString stdenv.hostPlatform.isDarwin '' + make "SED=sed -i" dist + ''; + installPhase = '' runHook preInstall + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' install -D -m755 -t $out/bin Rack install -D -m755 -t $out/lib libRack.so @@ -245,17 +319,34 @@ stdenv.mkDerivation rec { fi install -Dm644 icon_"$size"x"$size"x32.png $out/share/icons/hicolor/"$size"x"$size"/apps/Rack.png done; + '' + + lib.optionalString stdenv.isDarwin '' + mkdir -p $out/{bin,Applications} + mv dist/'VCV Rack ${lib.versions.major finalAttrs.version} Free.app' \ + $out/Applications + # plugins/Fundamental/dist/Fundamental-*.vcvplugin + cp -r res cacert.pem Core.json template.vcv LICENSE-GPLv3.txt \ + $out/Applications/'VCV Rack ${lib.versions.major finalAttrs.version} Free.app'/Contents/Resources + '' + + '' runHook postInstall ''; dontWrapGApps = true; - postFixup = '' - # Wrap gApp and override the default global resource file directory - wrapProgram $out/bin/Rack \ - "''${gappsWrapperArgs[@]}" \ - --add-flags "-s $out/share/vcv-rack" - ''; + postFixup = + lib.optionalString stdenv.hostPlatform.isLinux '' + # Wrap gApp and override the default global resource file directory + wrapProgram $out/bin/Rack \ + "''${gappsWrapperArgs[@]}" \ + --add-flags "-s $out/share/vcv-rack" + '' + + lib.optionalString stdenv.hostPlatform.isDarwin '' + makeWrapper \ + $out/Applications/'VCV Rack ${lib.versions.major finalAttrs.version} Free.app'/Contents/MacOS/Rack \ + $out/bin/${finalAttrs.meta.mainProgram} \ + --add-flags "-s $out/Applications/'VCV Rack ${lib.versions.major finalAttrs.version} Free.app'/Contents/Resources" + ''; meta = with lib; { description = "Open-source virtual modular synthesizer"; @@ -273,6 +364,6 @@ stdenv.mkDerivation rec { ddelabru ]; mainProgram = "Rack"; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; }; -} +}) diff --git a/pkgs/by-name/vc/vcv-rack/rack-minimize-vendoring.patch b/pkgs/by-name/vc/vcv-rack/rack-minimize-vendoring.patch index 58f1b1f16f07d..5e97b862ab835 100644 --- a/pkgs/by-name/vc/vcv-rack/rack-minimize-vendoring.patch +++ b/pkgs/by-name/vc/vcv-rack/rack-minimize-vendoring.patch @@ -1,13 +1,11 @@ -diff --git a/Makefile b/Makefile -index fc7c3af1..c3672c6a 100644 ---- a/Makefile -+++ b/Makefile -@@ -34,7 +34,7 @@ ifdef ARCH_LIN - - LDFLAGS += -Wl,--whole-archive - LDFLAGS += -static-libstdc++ -static-libgcc +diff --git i/Makefile w/Makefile +index 1d6accc6..fc09198e 100644 +--- i/Makefile ++++ w/Makefile +@@ -38 +38 @@ ifdef ARCH_LIN - LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a dep/lib/libarchive.a dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a dep/lib/librtmidi.a dep/lib/librtaudio.a + LDFLAGS += -lGLEW -lglfw -ljansson -lcurl -lssl -lcrypto -larchive -lz -lspeexdsp -lsamplerate -lrtmidi -lrtaudio - LDFLAGS += -Wl,--no-whole-archive - LDFLAGS += -lpthread -lGL -ldl -lX11 -lasound -ljack -lpulse -lpulse-simple - endif +@@ -52,2 +52 @@ ifdef ARCH_MAC +- LDFLAGS += -Wl,-all_load +- LDFLAGS += dep/lib/libGLEW.a dep/lib/libglfw3.a dep/lib/libjansson.a dep/lib/libcurl.a dep/lib/libssl.a dep/lib/libcrypto.a -Wl,-load_hidden,dep/lib/libarchive.a -Wl,-load_hidden,dep/lib/libzstd.a dep/lib/libspeexdsp.a dep/lib/libsamplerate.a -Wl,-load_hidden,dep/lib/librtmidi.a -Wl,-load_hidden,dep/lib/librtaudio.a ++ LDFLAGS += -Wl,-reexport-lGLEW -Wl,-reexport-lglfw -Wl,-reexport-ljansson -lcurl -lssl -lcrypto -larchive -lz -Wl,-reexport-lspeexdsp -lsamplerate -lrtmidi -lrtaudio