|
| 1 | +{ |
| 2 | + stdenv, |
| 3 | + lib, |
| 4 | + fetchFromGitHub, |
| 5 | + cmake, |
| 6 | + pkg-config, |
| 7 | + alsa-lib, |
| 8 | + freetype, |
| 9 | + fontconfig, |
| 10 | + curl, |
| 11 | + webkitgtk_4_1, |
| 12 | + glib, |
| 13 | + libsysprof-capture, |
| 14 | + pcre2, |
| 15 | + util-linux, |
| 16 | + libselinux, |
| 17 | + libsepol, |
| 18 | + libthai, |
| 19 | + libdatrie, |
| 20 | + libxdmcp, |
| 21 | + libdeflate, |
| 22 | + lerc, |
| 23 | + xz, |
| 24 | + libwebp, |
| 25 | + libxkbcommon, |
| 26 | + libepoxy, |
| 27 | + xorg, |
| 28 | + sqlite, |
| 29 | + |
| 30 | + buildVST3 ? true, |
| 31 | + buildClap ? true, |
| 32 | + buildStandalone ? true, |
| 33 | + buildLV2 ? stdenv.targetPlatform.isLinux, |
| 34 | + |
| 35 | + supplyAssets ? true, |
| 36 | + ... |
| 37 | +}: |
| 38 | +let |
| 39 | + inherit (lib) optional optionalString strings; |
| 40 | + |
| 41 | + versionDay = 16; |
| 42 | + date = "2025-11-${toString versionDay}"; |
| 43 | + fakeVersion = "0.8.${toString (versionDay + 1)}"; |
| 44 | + |
| 45 | + juceFormats = strings.join " " [ |
| 46 | + (optionalString buildVST3 "VST3") |
| 47 | + (optionalString buildStandalone "Standalone") |
| 48 | + (optionalString buildLV2 "LV2") |
| 49 | + ]; |
| 50 | +in |
| 51 | +stdenv.mkDerivation (finalAttrs: { |
| 52 | + pname = "OB-Xf"; |
| 53 | + version = "0-unstable-${date}"; |
| 54 | + |
| 55 | + src = fetchFromGitHub { |
| 56 | + owner = "surge-synthesizer"; |
| 57 | + repo = "OB-Xf"; |
| 58 | + tag = "ReWork"; |
| 59 | + hash = "sha256-NdWNybKlCLmepQ4OI63nztkSmrSggfNhZJFaPCQXuCI="; |
| 60 | + fetchSubmodules = true; |
| 61 | + }; |
| 62 | + |
| 63 | + patches = [ |
| 64 | + ./0001-juce-formats.diff |
| 65 | + ] |
| 66 | + ++ optional (!buildClap) ./0002-disable-clap.diff; |
| 67 | + |
| 68 | + postPatch = '' |
| 69 | + # Bypass versioning logic that relies on current date |
| 70 | + substituteInPlace CMakeLists.txt \ |
| 71 | + --replace-fail '0.''${PART0}.''${PART1}' "${fakeVersion}" |
| 72 | +
|
| 73 | + # Ignore warnings |
| 74 | + substituteInPlace CMakeLists.txt \ |
| 75 | + --replace-fail "-Werror" "-Wno-error" |
| 76 | +
|
| 77 | + substituteInPlace CMakeLists.txt \ |
| 78 | + --replace-fail "list(APPEND OBXF_JUCE_FORMATS VST3 Standalone)" \ |
| 79 | + "list(APPEND OBXF_JUCE_FORMATS ${juceFormats})" |
| 80 | +
|
| 81 | + cat > BUILD_VERSION << EOF |
| 82 | + SST_VERSION_INFO |
| 83 | + ${finalAttrs.src.rev} |
| 84 | + -no-tag- |
| 85 | + main |
| 86 | + Nightly-${date} |
| 87 | + EOF |
| 88 | + ''; |
| 89 | + |
| 90 | + cmakeFlags = [ |
| 91 | + "-DDISPLAY_VERSION=${fakeVersion}" |
| 92 | + "-DCOMMIT_HASH=${finalAttrs.src.rev}" |
| 93 | + "-DBRANCH=main" |
| 94 | + ]; |
| 95 | + |
| 96 | + nativeBuildInputs = [ |
| 97 | + cmake |
| 98 | + pkg-config |
| 99 | + ]; |
| 100 | + |
| 101 | + buildInputs = [ |
| 102 | + alsa-lib |
| 103 | + freetype |
| 104 | + fontconfig |
| 105 | + curl |
| 106 | + webkitgtk_4_1 |
| 107 | + glib |
| 108 | + libsysprof-capture |
| 109 | + pcre2 |
| 110 | + util-linux |
| 111 | + libselinux |
| 112 | + libsepol |
| 113 | + libthai |
| 114 | + libdatrie |
| 115 | + libxdmcp |
| 116 | + libdeflate |
| 117 | + lerc |
| 118 | + xz |
| 119 | + libwebp |
| 120 | + libxkbcommon |
| 121 | + libepoxy |
| 122 | + xorg.libXtst |
| 123 | + sqlite |
| 124 | + ]; |
| 125 | + |
| 126 | + configurePhase = '' |
| 127 | + runHook preConfigure |
| 128 | + cmake -B Builds/Release -DCMAKE_BUILD_TYPE=Release . |
| 129 | + runHook postConfigure |
| 130 | + ''; |
| 131 | + |
| 132 | + buildPhase = '' |
| 133 | + runHook preBuild |
| 134 | + cmake --build Builds/Release --config Release --target obxf-staged |
| 135 | + runHook postBuild |
| 136 | + ''; |
| 137 | + |
| 138 | + installPhase = '' |
| 139 | + runHook preInstall |
| 140 | +
|
| 141 | + pushd Builds/Release/obxf_products |
| 142 | + ${optionalString buildStandalone '' |
| 143 | + mkdir -p $out/bin |
| 144 | + mv OB-Xf $out/bin/OB-Xf |
| 145 | + ''} |
| 146 | +
|
| 147 | + ${optionalString buildClap '' |
| 148 | + mkdir -p $out/lib/clap |
| 149 | + mv OB-Xf.clap $out/lib/clap/ |
| 150 | + ''} |
| 151 | +
|
| 152 | + ${optionalString buildVST3 '' |
| 153 | + mkdir -p $out/lib/vst3 |
| 154 | + mv OB-Xf.vst3 $out/lib/vst3/ |
| 155 | + ''} |
| 156 | +
|
| 157 | + ${optionalString buildLV2 '' |
| 158 | + mkdir -p $out/lib/lv2 |
| 159 | + mv OB-Xf.lv2 $out/lib/lv2/ |
| 160 | + ''} |
| 161 | + popd |
| 162 | +
|
| 163 | + ${optionalString supplyAssets '' |
| 164 | + mkdir -p $out/share |
| 165 | + cp -r "assets/installer/Surge Synth Team" $out/share/ |
| 166 | + ''} |
| 167 | +
|
| 168 | + runHook postInstall |
| 169 | + ''; |
| 170 | + |
| 171 | + # TODO: enable auto-updates when OB-Xf is no longer in beta state |
| 172 | + # passthru.updateScript = nix-update-script { }; |
| 173 | + |
| 174 | + NIX_LDFLAGS = ( |
| 175 | + toString [ |
| 176 | + "-lX11" |
| 177 | + "-lXext" |
| 178 | + "-lXcomposite" |
| 179 | + "-lXcursor" |
| 180 | + "-lXinerama" |
| 181 | + "-lXrandr" |
| 182 | + "-lXrender" |
| 183 | + "-lXtst" |
| 184 | + "-lXdmcp" |
| 185 | + ] |
| 186 | + ); |
| 187 | + |
| 188 | + meta = { |
| 189 | + description = "Continuation of the last open source version of OB-Xd"; |
| 190 | + homepage = "https://github.com/surge-synthesizer/OB-Xf"; |
| 191 | + license = lib.licenses.gpl3; |
| 192 | + platforms = [ "x86_64-linux" ]; |
| 193 | + maintainers = [ lib.maintainers.mrtnvgr ]; |
| 194 | + mainProgram = optionalString buildStandalone "OB-Xf"; |
| 195 | + }; |
| 196 | +}) |
0 commit comments