nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 182 lines 4.5 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 gitUpdater, 6 apple-sdk_11, 7 cmake, 8 pkg-config, 9 ninja, 10 makeWrapper, 11 libjack2, 12 alsa-lib, 13 alsa-tools, 14 freetype, 15 jsoncpp, 16 libusb1, 17 libX11, 18 libXrandr, 19 libXinerama, 20 libXext, 21 libXcursor, 22 libXScrnSaver, 23 libGL, 24 libxcb, 25 vst2-sdk, 26 xcbutil, 27 libxkbcommon, 28 xcbutilkeysyms, 29 xcb-util-cursor, 30 gtk3, 31 webkitgtk_4_1, 32 python3, 33 curl, 34 pcre, 35 mount, 36 zenity, 37 # It is not allowed to distribute binaries with the VST2 SDK plugin without a license 38 # (the author of Bespoke has such a licence but not Nix). VST3 should work out of the box. 39 # Read more in https://github.com/NixOS/nixpkgs/issues/145607 40 enableVST2 ? false, 41}: 42 43stdenv.mkDerivation (finalAttrs: { 44 pname = "bespokesynth"; 45 version = "1.3.0"; 46 47 src = fetchFromGitHub { 48 owner = "BespokeSynth"; 49 repo = "bespokesynth"; 50 rev = "v${finalAttrs.version}"; 51 hash = "sha256-ad8wdLos3jM0gRMpcfRKeaiUxJsPGqWd/7XeDz87ToQ="; 52 fetchSubmodules = true; 53 }; 54 55 patches = [ 56 # Fix compatibility with pipewire's JACK emulation 57 # https://github.com/BespokeSynth/BespokeSynth/issues/1405#issuecomment-1721437868 58 ./2001-bespokesynth-fix-pipewire-jack.patch 59 ]; 60 61 # Linux builds are sandboxed properly, this always returns "localhost" there. 62 # Darwin builds doesn't have the same amount of sandboxing by default, and the builder's hostname is returned. 63 # In case this ever gets embedded into VersionInfoBld.cpp, hardcode it to the Linux value 64 postPatch = '' 65 substituteInPlace Source/cmake/versiontools.cmake \ 66 --replace-fail 'cmake_host_system_information(RESULT BESPOKE_BUILD_FQDN QUERY FQDN)' 'set(BESPOKE_BUILD_FQDN "localhost")' 67 ''; 68 69 cmakeBuildType = "Release"; 70 71 cmakeFlags = [ 72 (lib.cmakeBool "BESPOKE_SYSTEM_PYBIND11" true) 73 (lib.cmakeBool "BESPOKE_SYSTEM_JSONCPP" true) 74 ] 75 ++ lib.optionals enableVST2 [ 76 (lib.cmakeFeature "BESPOKE_VST2_SDK_LOCATION" "${vst2-sdk}") 77 ]; 78 79 strictDeps = true; 80 81 nativeBuildInputs = [ 82 python3 # interpreter 83 makeWrapper 84 cmake 85 pkg-config 86 ninja 87 ]; 88 89 buildInputs = [ 90 jsoncpp 91 # library & headers 92 (python3.withPackages ( 93 ps: with ps; [ 94 pybind11 95 ] 96 )) 97 ] 98 ++ lib.optionals stdenv.hostPlatform.isLinux [ 99 # List obtained from https://github.com/BespokeSynth/BespokeSynth/blob/main/azure-pipelines.yml 100 libX11 101 libXrandr 102 libXinerama 103 libXext 104 libXcursor 105 libXScrnSaver 106 curl 107 gtk3 108 webkitgtk_4_1 109 freetype 110 libGL 111 libusb1 112 alsa-lib 113 libjack2 114 zenity 115 alsa-tools 116 libxcb 117 xcbutil 118 libxkbcommon 119 xcbutilkeysyms 120 xcb-util-cursor 121 pcre 122 mount 123 ] 124 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 125 apple-sdk_11 126 ]; 127 128 postInstall = 129 if stdenv.hostPlatform.isDarwin then 130 '' 131 mkdir -p $out/{Applications,bin} 132 mv Source/BespokeSynth_artefacts/${finalAttrs.cmakeBuildType}/BespokeSynth.app $out/Applications/ 133 # Symlinking confuses the resource finding about the actual location of the binary 134 # Resources are looked up relative to the executed file's location 135 makeWrapper $out/{Applications/BespokeSynth.app/Contents/MacOS,bin}/BespokeSynth 136 '' 137 else 138 '' 139 # Ensure zenity is available, or it won't be able to open new files. 140 # Ensure the python used for compilation is the same as the python used at run-time. 141 # jedi is also required for auto-completion. 142 # These X11 libs get dlopen'd, they cause visual bugs when unavailable. 143 wrapProgram $out/bin/BespokeSynth \ 144 --prefix PATH : '${ 145 lib.makeBinPath [ 146 zenity 147 (python3.withPackages (ps: with ps; [ jedi ])) 148 ] 149 }' 150 ''; 151 152 env.NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isLinux "-rpath ${ 153 lib.makeLibraryPath ([ 154 libX11 155 libXrandr 156 libXinerama 157 libXext 158 libXcursor 159 libXScrnSaver 160 ]) 161 }"; 162 163 dontPatchELF = true; # needed or nix will try to optimize the binary by removing "useless" rpath 164 165 passthru.updateScript = gitUpdater { 166 rev-prefix = "v"; 167 }; 168 169 meta = { 170 description = "Software modular synth with controllers support, scripting and VST"; 171 homepage = "https://www.bespokesynth.com/"; 172 license = [ lib.licenses.gpl3Plus ]; 173 maintainers = with lib.maintainers; [ 174 astro 175 tobiasBora 176 OPNA2608 177 PowerUser64 178 ]; 179 mainProgram = "BespokeSynth"; 180 platforms = lib.platforms.all; 181 }; 182})