From 898f7b498b3dbc2eca495c5d6580f9c525b06630 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 22:23:38 +0100 Subject: [PATCH 1/8] bespokesynth: Modernise - rec -> finalAttrs - lib.cmakeFeature instead of manual CMake flag writing - meta-wide "with lib" begone Evals to the same output. --- .../audio/bespokesynth/default.nix | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index 8eb63539040c4e..e999bf14299f70 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -58,21 +58,23 @@ let }; in -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "bespokesynth"; version = "1.2.1"; src = fetchFromGitHub { owner = "BespokeSynth"; - repo = pname; - rev = "v${version}"; + repo = "bespokesynth"; + rev = "v${finalAttrs.version}"; hash = "sha256-vDvNm9sW9BfWloB0CA+JHTp/bfDWAP/T0hDXjoMZ3X4="; fetchSubmodules = true; }; cmakeBuildType = "Release"; - cmakeFlags = lib.optionals enableVST2 [ "-DBESPOKE_VST2_SDK_LOCATION=${vst-sdk}/VST2_SDK" ]; + cmakeFlags = lib.optionals enableVST2 [ + (lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst-sdk}/VST2_SDK") + ]; nativeBuildInputs = [ python3 @@ -128,7 +130,7 @@ stdenv.mkDerivation rec { if stdenv.hostPlatform.isDarwin then '' mkdir -p $out/{Applications,bin} - mv Source/BespokeSynth_artefacts/${cmakeBuildType}/BespokeSynth.app $out/Applications/ + mv Source/BespokeSynth_artefacts/${finalAttrs.cmakeBuildType}/BespokeSynth.app $out/Applications/ # Symlinking confuses the resource finding about the actual location of the binary # Resources are looked up relative to the executed file's location makeWrapper $out/{Applications/BespokeSynth.app/Contents/MacOS,bin}/BespokeSynth @@ -160,22 +162,22 @@ stdenv.mkDerivation rec { }"; dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath - meta = with lib; { + meta = { description = "Software modular synth with controllers support, scripting and VST"; homepage = "https://www.bespokesynth.com/"; license = - with licenses; + with lib.licenses; [ gpl3Plus ] ++ lib.optional enableVST2 unfree; - maintainers = with maintainers; [ + maintainers = with lib.maintainers; [ astro tobiasBora OPNA2608 PowerUser64 ]; mainProgram = "BespokeSynth"; - platforms = platforms.all; + platforms = lib.platforms.all; }; -} +}) From 3a117af47d70c443f7c0bedda470d3f6106b21a6 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 22:38:05 +0100 Subject: [PATCH 2/8] bespokesynth: Modernise (with rebuilds) - Enable strictDeps, adjust for resulting changes --- pkgs/applications/audio/bespokesynth/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index e999bf14299f70..ffa8f3ca73177f 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -76,8 +76,10 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst-sdk}/VST2_SDK") ]; + strictDeps = true; + nativeBuildInputs = [ - python3 + python3 # interpreter makeWrapper cmake pkg-config @@ -85,7 +87,10 @@ stdenv.mkDerivation (finalAttrs: { ]; buildInputs = - lib.optionals stdenv.hostPlatform.isLinux [ + [ + python3 # library + ] + ++ lib.optionals stdenv.hostPlatform.isLinux [ # List obtained from https://github.com/BespokeSynth/BespokeSynth/blob/main/azure-pipelines.yml libX11 libXrandr @@ -160,6 +165,7 @@ stdenv.mkDerivation (finalAttrs: { libXScrnSaver ]) }"; + dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath meta = { From 0a3fd92de049e5073d89cfaa8781f398179d633b Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 22:39:59 +0100 Subject: [PATCH 3/8] bespokesynth: Add passthru.updateScript So updates can be sent automatically by r-ryantm, assuming that no other adjustments are needed to build it. --- pkgs/applications/audio/bespokesynth/default.nix | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index ffa8f3ca73177f..51d444bc8ff7cb 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -3,6 +3,7 @@ stdenv, fetchFromGitHub, fetchzip, + gitUpdater, cmake, pkg-config, ninja, @@ -168,6 +169,10 @@ stdenv.mkDerivation (finalAttrs: { dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath + passthru.updateScript = gitUpdater { + rev-prefix = "v"; + }; + meta = { description = "Software modular synth with controllers support, scripting and VST"; homepage = "https://www.bespokesynth.com/"; From 5bc6acc80df0e98d17bba59f8f9d65905d1ba18f Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 22:52:18 +0100 Subject: [PATCH 4/8] bespokesynth: 1.2.1 -> 1.3.0 --- pkgs/applications/audio/bespokesynth/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index 51d444bc8ff7cb..29a3755361b8b6 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -61,13 +61,13 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "bespokesynth"; - version = "1.2.1"; + version = "1.3.0"; src = fetchFromGitHub { owner = "BespokeSynth"; repo = "bespokesynth"; rev = "v${finalAttrs.version}"; - hash = "sha256-vDvNm9sW9BfWloB0CA+JHTp/bfDWAP/T0hDXjoMZ3X4="; + hash = "sha256-ad8wdLos3jM0gRMpcfRKeaiUxJsPGqWd/7XeDz87ToQ="; fetchSubmodules = true; }; From e8ca293bb3b569bee16ce071d38ea0140b88992f Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 23:05:24 +0100 Subject: [PATCH 5/8] bespokesynth: Use more system dependencies --- .../audio/bespokesynth/default.nix | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index 29a3755361b8b6..5367642427b8b6 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -12,6 +12,7 @@ alsa-lib, alsa-tools, freetype, + jsoncpp, libusb1, libX11, libXrandr, @@ -73,9 +74,14 @@ stdenv.mkDerivation (finalAttrs: { cmakeBuildType = "Release"; - cmakeFlags = lib.optionals enableVST2 [ - (lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst-sdk}/VST2_SDK") - ]; + cmakeFlags = + [ + (lib.cmakeBool "BESPOKE_SYSTEM_PYBIND11" true) + (lib.cmakeBool "BESPOKE_SYSTEM_JSONCPP" true) + ] + ++ lib.optionals enableVST2 [ + (lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst-sdk}/VST2_SDK") + ]; strictDeps = true; @@ -89,7 +95,13 @@ stdenv.mkDerivation (finalAttrs: { buildInputs = [ - python3 # library + jsoncpp + # library & headers + (python3.withPackages ( + ps: with ps; [ + pybind11 + ] + )) ] ++ lib.optionals stdenv.hostPlatform.isLinux [ # List obtained from https://github.com/BespokeSynth/BespokeSynth/blob/main/azure-pipelines.yml From 16267bf47023accd391750e66712722ec9826ec9 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 23:35:01 +0100 Subject: [PATCH 6/8] bespokesynth: Hardcode queried FQDN Noticed while testing on Darwin, didn't expect to see my machine's hostname in the logs. --- pkgs/applications/audio/bespokesynth/default.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/applications/audio/bespokesynth/default.nix index 5367642427b8b6..3bf68d11bd88ea 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/applications/audio/bespokesynth/default.nix @@ -72,6 +72,14 @@ stdenv.mkDerivation (finalAttrs: { fetchSubmodules = true; }; + # Linux builds are sandboxed properly, this always returns "localhost" there. + # Darwin builds doesn't have the same amount of sandboxing by default, and the builder's hostname is returned. + # In case this ever gets embedded into VersionInfoBld.cpp, hardcode it to the Linux value + postPatch = '' + substituteInPlace Source/cmake/versiontools.cmake \ + --replace-fail 'cmake_host_system_information(RESULT BESPOKE_BUILD_FQDN QUERY FQDN)' 'set(BESPOKE_BUILD_FQDN "localhost")' + ''; + cmakeBuildType = "Release"; cmakeFlags = From ebdf35c4363d50703b134d859ccf327b3dc7d031 Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Mon, 23 Dec 2024 23:45:06 +0100 Subject: [PATCH 7/8] bespokesynth: Move to by-name --- .../be/bespokesynth/package.nix} | 21 ++----------------- pkgs/top-level/all-packages.nix | 4 ---- 2 files changed, 2 insertions(+), 23 deletions(-) rename pkgs/{applications/audio/bespokesynth/default.nix => by-name/be/bespokesynth/package.nix} (91%) diff --git a/pkgs/applications/audio/bespokesynth/default.nix b/pkgs/by-name/be/bespokesynth/package.nix similarity index 91% rename from pkgs/applications/audio/bespokesynth/default.nix rename to pkgs/by-name/be/bespokesynth/package.nix index 3bf68d11bd88ea..f2bf3a98d3392d 100644 --- a/pkgs/applications/audio/bespokesynth/default.nix +++ b/pkgs/by-name/be/bespokesynth/package.nix @@ -4,6 +4,7 @@ fetchFromGitHub, fetchzip, gitUpdater, + apple-sdk_11, cmake, pkg-config, ninja, @@ -33,13 +34,6 @@ pcre, mount, zenity, - Accelerate, - Cocoa, - WebKit, - CoreServices, - CoreAudioKit, - IOBluetooth, - MetalKit, # It is not allowed to distribute binaries with the VST2 SDK plugin without a license # (the author of Bespoke has such a licence but not Nix). VST3 should work out of the box. # Read more in https://github.com/NixOS/nixpkgs/issues/145607 @@ -138,20 +132,9 @@ stdenv.mkDerivation (finalAttrs: { mount ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ - Accelerate - Cocoa - WebKit - CoreServices - CoreAudioKit - IOBluetooth - MetalKit + apple-sdk_11 ]; - env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isDarwin (toString [ - # Fails to find fp.h on its own - "-isystem ${CoreServices}/Library/Frameworks/CoreServices.framework/Versions/Current/Frameworks/CarbonCore.framework/Versions/Current/Headers/" - ]); - postInstall = if stdenv.hostPlatform.isDarwin then '' diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 7057e25505318f..106e18c484cff6 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -13213,10 +13213,6 @@ with pkgs; barrier = libsForQt5.callPackage ../applications/misc/barrier { }; - bespokesynth = darwin.apple_sdk_11_0.callPackage ../applications/audio/bespokesynth { - inherit (darwin.apple_sdk_11_0.frameworks) Accelerate Cocoa WebKit CoreServices CoreAudioKit IOBluetooth MetalKit; - }; - bespokesynth-with-vst2 = bespokesynth.override { enableVST2 = true; }; From 450fcb57101e6f80da321f45836bf70a00d8c9bf Mon Sep 17 00:00:00 2001 From: OPNA2608 Date: Wed, 8 Jan 2025 15:12:47 +0100 Subject: [PATCH 8/8] bespokesynth: Fix compatibility with pipewire's JACK emulation --- .../2001-bespokesynth-fix-pipewire-jack.patch | 30 +++++++++++++++++++ pkgs/by-name/be/bespokesynth/package.nix | 6 ++++ 2 files changed, 36 insertions(+) create mode 100644 pkgs/by-name/be/bespokesynth/2001-bespokesynth-fix-pipewire-jack.patch diff --git a/pkgs/by-name/be/bespokesynth/2001-bespokesynth-fix-pipewire-jack.patch b/pkgs/by-name/be/bespokesynth/2001-bespokesynth-fix-pipewire-jack.patch new file mode 100644 index 00000000000000..c14848843bdc0e --- /dev/null +++ b/pkgs/by-name/be/bespokesynth/2001-bespokesynth-fix-pipewire-jack.patch @@ -0,0 +1,30 @@ +diff --git a/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp b/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp +index 4cce7016f..25554a7cd 100644 +--- a/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp ++++ b/libs/JUCE/modules/juce_audio_devices/native/juce_JackAudio_linux.cpp +@@ -291,7 +291,6 @@ public: + juce::jack_on_info_shutdown (client, infoShutdownCallback, this); + juce::jack_set_xrun_callback (client, xrunCallback, this); + juce::jack_activate (client); +- deviceIsOpen = true; + + if (! inputChannels.isZero()) + { +@@ -336,6 +335,7 @@ public: + } + + updateActivePorts(); ++ deviceIsOpen = true; + + return lastError; + } +@@ -525,7 +525,8 @@ private: + static void portConnectCallback (jack_port_id_t, jack_port_id_t, int, void* arg) + { + if (JackAudioIODevice* device = static_cast (arg)) +- device->mainThreadDispatcher.updateActivePorts(); ++ if (device->isOpen()) ++ device->mainThreadDispatcher.updateActivePorts(); + } + + static void threadInitCallback (void* /* callbackArgument */) diff --git a/pkgs/by-name/be/bespokesynth/package.nix b/pkgs/by-name/be/bespokesynth/package.nix index f2bf3a98d3392d..29ff82de7e2f23 100644 --- a/pkgs/by-name/be/bespokesynth/package.nix +++ b/pkgs/by-name/be/bespokesynth/package.nix @@ -66,6 +66,12 @@ stdenv.mkDerivation (finalAttrs: { fetchSubmodules = true; }; + patches = [ + # Fix compatibility with pipewire's JACK emulation + # https://github.com/BespokeSynth/BespokeSynth/issues/1405#issuecomment-1721437868 + ./2001-bespokesynth-fix-pipewire-jack.patch + ]; + # Linux builds are sandboxed properly, this always returns "localhost" there. # Darwin builds doesn't have the same amount of sandboxing by default, and the builder's hostname is returned. # In case this ever gets embedded into VersionInfoBld.cpp, hardcode it to the Linux value