1{ lib
2, stdenv
3, fetchurl
4, cmake
5, glib
6, nss
7, nspr
8, atk
9, at-spi2-atk
10, libdrm
11, expat
12, libxcb
13, libxkbcommon
14, libX11
15, libXcomposite
16, libXdamage
17, libXext
18, libXfixes
19, libXrandr
20, mesa
21, gtk3
22, pango
23, cairo
24, alsa-lib
25, dbus
26, at-spi2-core
27, cups
28, libxshmfence
29, obs-studio
30}:
31
32let
33 gl_rpath = lib.makeLibraryPath [
34 stdenv.cc.cc.lib
35 ];
36
37 rpath = lib.makeLibraryPath [
38 glib
39 nss
40 nspr
41 atk
42 at-spi2-atk
43 libdrm
44 expat
45 libxcb
46 libxkbcommon
47 libX11
48 libXcomposite
49 libXdamage
50 libXext
51 libXfixes
52 libXrandr
53 mesa
54 gtk3
55 pango
56 cairo
57 alsa-lib
58 dbus
59 at-spi2-core
60 cups
61 libxshmfence
62 ];
63 platforms = {
64 "aarch64-linux" = {
65 platformStr = "linuxarm64";
66 projectArch = "arm64";
67 };
68 "x86_64-linux" = {
69 platformStr = "linux64";
70 projectArch = "x86_64";
71 };
72 };
73 platforms."aarch64-linux".sha256 = "16sbfk599h96wcsmpbxlwsvq0n1pssmm8dpwmjsqfrn1464dvs68";
74 platforms."x86_64-linux".sha256 = "1wa4nv28saz96kar9svdarfz6c4rnbcqz0rqxzl9zclnhfzhqdiw";
75
76 platformInfo = platforms.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
77in
78stdenv.mkDerivation rec {
79 pname = "cef-binary";
80 version = "121.3.13";
81 gitRevision = "5c4a81b";
82 chromiumVersion = "121.0.6167.184";
83
84 src = fetchurl {
85 url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${platformInfo.platformStr}_minimal.tar.bz2";
86 inherit (platformInfo) sha256;
87 };
88
89 nativeBuildInputs = [ cmake ];
90 cmakeFlags = [ "-DPROJECT_ARCH=${platformInfo.projectArch}" ];
91 makeFlags = [ "libcef_dll_wrapper" ];
92 dontStrip = true;
93 dontPatchELF = true;
94
95 installPhase = ''
96 mkdir -p $out/lib/ $out/share/cef/
97 cp libcef_dll_wrapper/libcef_dll_wrapper.a $out/lib/
98 cp ../Release/libcef.so $out/lib/
99 cp ../Release/libEGL.so $out/lib/
100 cp ../Release/libGLESv2.so $out/lib/
101 patchelf --set-rpath "${rpath}" $out/lib/libcef.so
102 patchelf --set-rpath "${gl_rpath}" $out/lib/libEGL.so
103 patchelf --set-rpath "${gl_rpath}" $out/lib/libGLESv2.so
104 cp ../Release/*.bin $out/share/cef/
105 cp -r ../Resources/* $out/share/cef/
106 cp -r ../include $out/
107 '';
108
109 passthru.tests = {
110 inherit obs-studio; # frequently breaks on CEF updates
111 };
112 passthru.updateScript = ./update.sh;
113
114 meta = with lib; {
115 description = "Simple framework for embedding Chromium-based browsers in other applications";
116 homepage = "https://cef-builds.spotifycdn.com/index.html";
117 maintainers = with maintainers; [ puffnfresh ];
118 sourceProvenance = with sourceTypes; [
119 fromSource
120 binaryNativeCode
121 ];
122 license = licenses.bsd3;
123 platforms = [ "x86_64-linux" "aarch64-linux" ];
124 };
125}