biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / video / obs-studio / default.nix
blob3df52d08684d52b9d83e9141b0f73dae3eae6bd0
1 { config
2 , lib
3 , stdenv
4 , fetchFromGitHub
5 , fetchpatch
6 , addOpenGLRunpath
7 , cmake
8 , fdk_aac
9 , ffmpeg
10 , jansson
11 , libjack2
12 , libxkbcommon
13 , libpthreadstubs
14 , libXdmcp
15 , qtbase
16 , qtsvg
17 , speex
18 , libv4l
19 , x264
20 , curl
21 , wayland
22 , xorg
23 , pkg-config
24 , libvlc
25 , libGL
26 , mbedtls
27 , wrapGAppsHook
28 , scriptingSupport ? true
29 , luajit
30 , swig4
31 , python3
32 , alsaSupport ? stdenv.isLinux
33 , alsa-lib
34 , pulseaudioSupport ? config.pulseaudio or stdenv.isLinux
35 , libpulseaudio
36 , libcef
37 , pciutils
38 , pipewireSupport ? stdenv.isLinux
39 , withFdk ? true
40 , pipewire
41 , libdrm
42 , libajantv2
43 , librist
44 , libva
45 , srt
46 , qtwayland
47 , wrapQtAppsHook
48 , nlohmann_json
49 , websocketpp
50 , asio
51 , decklinkSupport ? false
52 , blackmagic-desktop-video
53 , libdatachannel
54 , libvpl
55 , qrcodegencpp
56 , nix-update-script
59 let
60   inherit (lib) optional optionals;
63 stdenv.mkDerivation (finalAttrs: {
64   pname = "obs-studio";
65   version = "30.1.2";
67   src = fetchFromGitHub {
68     owner = "obsproject";
69     repo = finalAttrs.pname;
70     rev = finalAttrs.version;
71     sha256 = "sha256-M4IINBoYrgkM37ykb4boHyWP8AxwMX0b7IAeeNIw9Qo=";
72     fetchSubmodules = true;
73   };
75   patches = [
76     # Lets obs-browser build against CEF 90.1.0+
77     ./Enable-file-access-and-universal-access-for-file-URL.patch
78     ./fix-nix-plugin-path.patch
80     # Fix libobs.pc for plugins on non-x86 systems
81     (fetchpatch {
82       name = "fix-arm64-cmake.patch";
83       url = "https://git.alpinelinux.org/aports/plain/community/obs-studio/broken-config.patch?id=a92887564dcc65e07b6be8a6224fda730259ae2b";
84       hash = "sha256-yRSw4VWDwMwysDB3Hw/tsmTjEQUhipvrVRQcZkbtuoI=";
85       includes = [ "*/CompilerConfig.cmake" ];
86     })
87   ];
89   nativeBuildInputs = [
90     addOpenGLRunpath
91     cmake
92     pkg-config
93     wrapGAppsHook
94     wrapQtAppsHook
95   ]
96   ++ optional scriptingSupport swig4;
98   buildInputs = [
99     curl
100     ffmpeg
101     jansson
102     libcef
103     libjack2
104     libv4l
105     libxkbcommon
106     libpthreadstubs
107     libXdmcp
108     qtbase
109     qtsvg
110     speex
111     wayland
112     x264
113     libvlc
114     mbedtls
115     pciutils
116     libajantv2
117     librist
118     libva
119     srt
120     qtwayland
121     nlohmann_json
122     websocketpp
123     asio
124     libdatachannel
125     libvpl
126     qrcodegencpp
127   ]
128   ++ optionals scriptingSupport [ luajit python3 ]
129   ++ optional alsaSupport alsa-lib
130   ++ optional pulseaudioSupport libpulseaudio
131   ++ optionals pipewireSupport [ pipewire libdrm ]
132   ++ optional withFdk fdk_aac;
134   # Copied from the obs-linuxbrowser
135   postUnpack = ''
136     mkdir -p cef/Release cef/Resources cef/libcef_dll_wrapper/
137     for i in ${libcef}/share/cef/*; do
138       ln -s $i cef/Release/
139       ln -s $i cef/Resources/
140     done
141     ln -s ${libcef}/lib/libcef.so cef/Release/
142     ln -s ${libcef}/lib/libcef_dll_wrapper.a cef/libcef_dll_wrapper/
143     ln -s ${libcef}/include cef/
144   '';
146   cmakeFlags = [
147     "-DOBS_VERSION_OVERRIDE=${finalAttrs.version}"
148     "-Wno-dev" # kill dev warnings that are useless for packaging
149     # Add support for browser source
150     "-DBUILD_BROWSER=ON"
151     "-DCEF_ROOT_DIR=../../cef"
152     "-DENABLE_JACK=ON"
153     (lib.cmakeBool "ENABLE_QSV11" stdenv.hostPlatform.isx86_64)
154     (lib.cmakeBool "ENABLE_LIBFDK" withFdk)
155     (lib.cmakeBool "ENABLE_ALSA" alsaSupport)
156     (lib.cmakeBool "ENABLE_PULSEAUDIO" pulseaudioSupport)
157     (lib.cmakeBool "ENABLE_PIPEWIRE" pipewireSupport)
158   ];
160   env.NIX_CFLAGS_COMPILE = toString [
161     "-Wno-error=sign-compare" # https://github.com/obsproject/obs-studio/issues/10200
162   ];
164   dontWrapGApps = true;
165   preFixup = let
166     wrapperLibraries = [
167       xorg.libX11
168       libvlc
169       libGL
170     ] ++ optionals decklinkSupport [
171       blackmagic-desktop-video
172     ];
173   in ''
174     # Remove libcef before patchelf, otherwise it will fail
175     rm $out/lib/obs-plugins/libcef.so
177     qtWrapperArgs+=(
178       --prefix LD_LIBRARY_PATH : "$out/lib:${lib.makeLibraryPath wrapperLibraries}"
179       ''${gappsWrapperArgs[@]}
180     )
181   '';
183   postFixup = lib.optionalString stdenv.isLinux ''
184     addOpenGLRunpath $out/lib/lib*.so
185     addOpenGLRunpath $out/lib/obs-plugins/*.so
187     # Link libcef again after patchelfing other libs
188     ln -s ${libcef}/lib/* $out/lib/obs-plugins/
189   '';
191   passthru.updateScript = nix-update-script { };
193   meta = with lib; {
194     description = "Free and open source software for video recording and live streaming";
195     longDescription = ''
196       This project is a rewrite of what was formerly known as "Open Broadcaster
197       Software", software originally designed for recording and streaming live
198       video content, efficiently
199     '';
200     homepage = "https://obsproject.com";
201     maintainers = with maintainers; [ eclairevoyant jb55 MP2E materus fpletz ];
202     license = with licenses; [ gpl2Plus ] ++ optional withFdk fraunhofer-fdk;
203     platforms = [ "x86_64-linux" "i686-linux" "aarch64-linux" ];
204     mainProgram = "obs";
205   };