nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 autoPatchelfHook,
3 fetchFromGitHub,
4 fetchurl,
5 fetchpatch,
6 stdenv,
7 cmake,
8 python3,
9 jdk,
10 git,
11 rsync,
12 lib,
13 ant,
14 ninja,
15 strip-nondeterminism,
16 stripJavaArchivesHook,
17
18 debugBuild ? false,
19
20 nss,
21 nspr,
22 libGL,
23 libX11,
24 libXdamage,
25 boost,
26 thrift,
27 cef-binary,
28}:
29
30let
31 buildType = if debugBuild then "Debug" else "Release";
32 platform =
33 {
34 "aarch64-linux" = "linuxarm64";
35 "x86_64-linux" = "linux64";
36 }
37 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
38 arches =
39 {
40 "linuxarm64" = {
41 depsArch = "arm64";
42 projectArch = "arm64";
43 targetArch = "arm64";
44 };
45 "linux64" = {
46 depsArch = "amd64";
47 projectArch = "x86_64";
48 targetArch = "x86_64";
49 };
50 }
51 .${platform};
52 inherit (arches) depsArch projectArch targetArch;
53
54 # `cef_binary_${CEF_VERSION}_linux64_minimal`, where CEF_VERSION is from $src/CMakeLists.txt
55 cef-name = "cef_binary_137.0.17+gf354b0e+chromium-137.0.7151.104_${platform}_minimal";
56
57 cef-bin = cef-binary.override {
58 version = "137.0.17"; # follow upstream. https://github.com/Almamu/linux-wallpaperengine/blob/b39f12757908eda9f4c1039613b914606568bb84/CMakeLists.txt#L47
59 gitRevision = "f354b0e";
60 chromiumVersion = "137.0.7151.104";
61 srcHashes = {
62 aarch64-linux = "sha256-C9P4+TpzjyMD5z2qLbzubbrIr66usFjRx7QqiAxI2D8=";
63 x86_64-linux = "sha256-iDC3a/YN0NqjX/b2waKvUAZCaR0lkLmUPqBJphE037Q=";
64 };
65 };
66
67 thrift20 = thrift.overrideAttrs (old: {
68 version = "0.20.0";
69
70 src = fetchFromGitHub {
71 owner = "apache";
72 repo = "thrift";
73 tag = "v0.20.0";
74 hash = "sha256-cwFTcaNHq8/JJcQxWSelwAGOLvZHoMmjGV3HBumgcWo=";
75 };
76
77 cmakeFlags = (old.cmakeFlags or [ ]) ++ [
78 "-DCMAKE_POLICY_VERSION_MINIMUM=3.10"
79 ];
80 patches = (old.patches or [ ]) ++ [
81 # Fix build with gcc15
82 # https://github.com/apache/thrift/pull/3078
83 (fetchpatch {
84 name = "thrift-add-missing-cstdint-include-gcc15.patch";
85 url = "https://github.com/apache/thrift/commit/947ad66940cfbadd9b24ba31d892dfc1142dd330.patch";
86 hash = "sha256-pWcG6/BepUwc/K6cBs+6d74AWIhZ2/wXvCunb/KyB0s=";
87 })
88 ];
89 });
90
91in
92stdenv.mkDerivation rec {
93 pname = "jcef-jetbrains";
94 rev = "6f9ab690b28a1262f82e6f869c310bdf1d0697ac";
95 # This is the commit number
96 # Currently from the branch: https://github.com/JetBrains/jcef/tree/251
97 # Run `git rev-list --count HEAD`
98 version = "1086";
99
100 nativeBuildInputs = [
101 cmake
102 python3
103 jdk
104 git
105 rsync
106 ant
107 ninja
108 strip-nondeterminism
109 stripJavaArchivesHook
110 autoPatchelfHook
111 ];
112 buildInputs = [
113 boost
114 libGL
115 libX11
116 libXdamage
117 nss
118 nspr
119 thrift20
120 ];
121
122 src = fetchFromGitHub {
123 owner = "jetbrains";
124 repo = "jcef";
125 inherit rev;
126 hash = "sha256-w5t1M66KW5cUbNTpAc4ksGd+414EJsXwbq1UP1COFsw=";
127 };
128
129 # Find the hash in tools/buildtools/linux64/clang-format.sha1
130 clang-fmt = fetchurl {
131 url = "https://storage.googleapis.com/chromium-clang-format/dd736afb28430c9782750fc0fd5f0ed497399263";
132 hash = "sha256-4H6FVO9jdZtxH40CSfS+4VESAHgYgYxfCBFSMHdT0hE=";
133 };
134
135 configurePhase = ''
136 runHook preConfigure
137
138 patchShebangs .
139
140 cp -r ${cef-bin} third_party/cef/${cef-name}
141 chmod +w -R third_party/cef/${cef-name}
142
143 sed \
144 -e 's|os.path.isdir(os.path.join(path, \x27.git\x27))|True|' \
145 -e 's|"%s rev-parse %s" % (git_exe, branch)|"echo '${rev}'"|' \
146 -e 's|"%s config --get remote.origin.url" % git_exe|"echo 'https://github.com/jetbrains/jcef'"|' \
147 -e 's|"%s rev-list --count %s" % (git_exe, branch)|"echo '${version}'"|' \
148 -i tools/git_util.py
149
150 cp ${clang-fmt} tools/buildtools/linux64/clang-format
151 chmod +w tools/buildtools/linux64/clang-format
152
153 sed \
154 -e 's|include(cmake/vcpkg.cmake)||' \
155 -e 's|bring_vcpkg()||' \
156 -e 's|vcpkg_install_package(boost-filesystem boost-interprocess thrift)||' \
157 -i CMakeLists.txt
158
159 sed -e 's|vcpkg_bring_host_thrift()|set(THRIFT_COMPILER_HOST ${lib.getExe thrift20})|' -i remote/CMakeLists.txt
160
161 mkdir jcef_build
162 cd jcef_build
163
164 cmake -G "Ninja" -DPROJECT_ARCH="${projectArch}" -DCMAKE_BUILD_TYPE=${buildType} ..
165
166 runHook postConfigure
167 '';
168
169 outputs = [
170 "out"
171 ];
172
173 postBuild = ''
174 export JCEF_ROOT_DIR=$(realpath ..)
175 ../tools/compile.sh ${platform} Release
176 '';
177
178 installPhase = ''
179 runHook preInstall
180
181 export JCEF_ROOT_DIR=$(realpath ..)
182 export OUT_NATIVE_DIR=$JCEF_ROOT_DIR/jcef_build/native/${buildType}
183 export OUT_REMOTE_DIR=$JCEF_ROOT_DIR/jcef_build/remote/${buildType}
184 export JB_TOOLS_DIR=$(realpath ../jb/tools)
185 export JB_TOOLS_OS_DIR=$JB_TOOLS_DIR/linux
186 export OUT_CLS_DIR=$(realpath ../out/${platform})
187 export TARGET_ARCH=${targetArch} DEPS_ARCH=${depsArch}
188 export OS=linux
189 export JOGAMP_DIR="$JCEF_ROOT_DIR"/third_party/jogamp/jar
190
191 bash "$JB_TOOLS_DIR"/common/create_modules.sh
192
193 mkdir -p $out
194
195 bash "$JB_TOOLS_DIR"/common/create_version_file.sh $out
196
197 cp -r $JCEF_ROOT_DIR/jmods/ $out
198 cp -r $JCEF_ROOT_DIR/cef_server/ $out
199
200 runHook postInstall
201 '';
202
203 dontStrip = debugBuild;
204
205 postFixup = ''
206 # stripJavaArchivesHook gets rid of jar file timestamps, but not of jmod file timestamps
207 # We have to manually call strip-nondeterminism to do this for jmod files too
208 find $out -name "*.jmod" -exec strip-nondeterminism --type jmod {} +
209 '';
210
211 meta = {
212 description = "Jetbrains' fork of JCEF";
213 license = lib.licenses.bsd3;
214 homepage = "https://github.com/JetBrains/JCEF";
215 platforms = [
216 "aarch64-linux"
217 "x86_64-linux"
218 ];
219 maintainers = with lib.maintainers; [
220 aoli-al
221 ];
222 };
223}