Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 252 lines 5.9 kB view raw
1{ 2 config, 3 uthash, 4 lib, 5 stdenv, 6 ninja, 7 nv-codec-headers-12, 8 fetchFromGitHub, 9 addDriverRunpath, 10 autoAddDriverRunpath, 11 cudaSupport ? config.cudaSupport, 12 cmake, 13 fdk_aac, 14 ffmpeg, 15 jansson, 16 libjack2, 17 libxkbcommon, 18 libpthreadstubs, 19 libXdmcp, 20 qtbase, 21 qtsvg, 22 speex, 23 libv4l, 24 x264, 25 curl, 26 wayland, 27 xorg, 28 pkg-config, 29 libvlc, 30 libGL, 31 mbedtls, 32 wrapGAppsHook3, 33 scriptingSupport ? true, 34 luajit, 35 swig, 36 python3, 37 alsaSupport ? stdenv.hostPlatform.isLinux, 38 alsa-lib, 39 pulseaudioSupport ? config.pulseaudio or stdenv.hostPlatform.isLinux, 40 libpulseaudio, 41 browserSupport ? true, 42 cef-binary, 43 pciutils, 44 pipewireSupport ? stdenv.hostPlatform.isLinux, 45 withFdk ? true, 46 pipewire, 47 libdrm, 48 librist, 49 cjson, 50 libva, 51 srt, 52 qtwayland, 53 wrapQtAppsHook, 54 nlohmann_json, 55 websocketpp, 56 asio, 57 decklinkSupport ? false, 58 blackmagic-desktop-video, 59 libdatachannel, 60 libvpl, 61 qrcodegencpp, 62 nix-update-script, 63 extra-cmake-modules, 64}: 65 66let 67 inherit (lib) optional optionals; 68 69 cef = cef-binary.overrideAttrs (oldAttrs: { 70 version = "138.0.17"; 71 __intentionallyOverridingVersion = true; # `cef-binary` uses the overridden `srcHash` values in its source FOD 72 gitRevision = "ac9b751"; 73 chromiumVersion = "138.0.7204.97"; 74 75 srcHash = 76 { 77 aarch64-linux = "sha256-kdO7c9oUfv0HK8wTmvYzw9S6EapnSGEQNCGN9D1JSL0="; 78 x86_64-linux = "sha256-3qgIhen6l/kxttyw0z78nmwox62riVhlmFSGPkUot7g="; 79 } 80 .${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); 81 }); 82in 83stdenv.mkDerivation (finalAttrs: { 84 pname = "obs-studio"; 85 version = "31.1.2"; 86 87 src = fetchFromGitHub { 88 owner = "obsproject"; 89 repo = "obs-studio"; 90 rev = finalAttrs.version; 91 hash = "sha256-QZoIyjliVruDPZj8hzTABaDn+nCTVs5qQCdBLtSOKvI="; 92 fetchSubmodules = true; 93 }; 94 95 separateDebugInfo = true; 96 97 patches = [ 98 # Lets obs-browser build against CEF 90.1.0+ 99 ./Enable-file-access-and-universal-access-for-file-URL.patch 100 ./fix-nix-plugin-path.patch 101 ]; 102 103 nativeBuildInputs = [ 104 addDriverRunpath 105 cmake 106 ninja 107 pkg-config 108 wrapGAppsHook3 109 wrapQtAppsHook 110 extra-cmake-modules 111 ] 112 ++ optional scriptingSupport swig 113 ++ optional cudaSupport autoAddDriverRunpath; 114 115 buildInputs = [ 116 curl 117 ffmpeg 118 jansson 119 libjack2 120 libv4l 121 libxkbcommon 122 libpthreadstubs 123 libXdmcp 124 qtbase 125 qtsvg 126 speex 127 wayland 128 x264 129 libvlc 130 mbedtls 131 pciutils 132 librist 133 cjson 134 libva 135 srt 136 qtwayland 137 nlohmann_json 138 websocketpp 139 asio 140 libdatachannel 141 libvpl 142 qrcodegencpp 143 uthash 144 nv-codec-headers-12 145 ] 146 ++ optionals scriptingSupport [ 147 luajit 148 python3 149 ] 150 ++ optional alsaSupport alsa-lib 151 ++ optional pulseaudioSupport libpulseaudio 152 ++ optionals pipewireSupport [ 153 pipewire 154 libdrm 155 ] 156 ++ optional browserSupport cef 157 ++ optional withFdk fdk_aac; 158 159 # Copied from the obs-linuxbrowser 160 postUnpack = lib.optionalString browserSupport '' 161 ln -s ${cef} cef 162 ''; 163 164 postPatch = '' 165 cp ${./CMakeUserPresets.json} ./CMakeUserPresets.json 166 ''; 167 168 cmakeFlags = [ 169 "--preset" 170 "nixpkgs-${if stdenv.hostPlatform.isDarwin then "darwin" else "linux"}" 171 "-DOBS_VERSION_OVERRIDE=${finalAttrs.version}" 172 "-Wno-dev" # kill dev warnings that are useless for packaging 173 "-DENABLE_JACK=ON" 174 "-DENABLE_WEBRTC=ON" 175 (lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64) 176 (lib.cmakeBool "ENABLE_LIBFDK" withFdk) 177 (lib.cmakeBool "ENABLE_ALSA" alsaSupport) 178 (lib.cmakeBool "ENABLE_PULSEAUDIO" pulseaudioSupport) 179 (lib.cmakeBool "ENABLE_PIPEWIRE" pipewireSupport) 180 (lib.cmakeBool "ENABLE_AJA" false) # TODO: fix linking against libajantv2 181 (lib.cmakeBool "ENABLE_BROWSER" browserSupport) 182 ] 183 ++ lib.optional browserSupport "-DCEF_ROOT_DIR=../../cef"; 184 185 env.NIX_CFLAGS_COMPILE = toString [ 186 "-Wno-error=deprecated-declarations" 187 "-Wno-error=sign-compare" # https://github.com/obsproject/obs-studio/issues/10200 188 "-Wno-error=stringop-overflow=" 189 ]; 190 191 dontWrapGApps = true; 192 preFixup = 193 let 194 wrapperLibraries = [ 195 xorg.libX11 196 libvlc 197 libGL 198 ] 199 ++ optionals decklinkSupport [ blackmagic-desktop-video ]; 200 in 201 '' 202 qtWrapperArgs+=( 203 --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}" 204 ''${gappsWrapperArgs[@]} 205 ) 206 '' 207 + lib.optionalString browserSupport '' 208 # Remove cef components before patchelf, otherwise it will fail 209 rm $out/lib/obs-plugins/libcef.so 210 rm $out/lib/obs-plugins/libEGL.so 211 rm $out/lib/obs-plugins/libGLESv2.so 212 rm $out/lib/obs-plugins/libvk_swiftshader.so 213 rm $out/lib/obs-plugins/libvulkan.so.1 214 rm $out/lib/obs-plugins/chrome-sandbox 215 ''; 216 217 postFixup = lib.concatStrings [ 218 (lib.optionalString stdenv.hostPlatform.isLinux '' 219 addDriverRunpath $out/lib/lib*.so 220 addDriverRunpath $out/lib/obs-plugins/*.so 221 '') 222 223 (lib.optionalString browserSupport '' 224 # Link cef components again after patchelfing other libs 225 ln -sf ${cef}/${cef.buildType}/* $out/lib/obs-plugins/ 226 '') 227 ]; 228 229 passthru.updateScript = nix-update-script { }; 230 231 meta = with lib; { 232 description = "Free and open source software for video recording and live streaming"; 233 longDescription = '' 234 This project is a rewrite of what was formerly known as "Open Broadcaster 235 Software", software originally designed for recording and streaming live 236 video content, efficiently 237 ''; 238 homepage = "https://obsproject.com"; 239 maintainers = with maintainers; [ 240 jb55 241 materus 242 fpletz 243 ]; 244 license = with licenses; [ gpl2Plus ] ++ optional withFdk fraunhofer-fdk; 245 platforms = [ 246 "x86_64-linux" 247 "i686-linux" 248 "aarch64-linux" 249 ]; 250 mainProgram = "obs"; 251 }; 252})