Skip to content

Commit cc904b8

Browse files
superblaubeere271zun4
authored andcommitted
Create default.nix
1 parent 52e7dab commit cc904b8

File tree

1 file changed

+179
-0
lines changed

1 file changed

+179
-0
lines changed

default.nix

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
{ pkgs ? import <nixpkgs> {} }:
2+
3+
assert !pkgs.stdenv.hostPlatform.isDarwin;
4+
# I can't test darwin
5+
6+
let
7+
rpath = pkgs.lib.makeLibraryPath (with pkgs; [
8+
glib
9+
nss
10+
nspr
11+
atk
12+
at-spi2-atk
13+
libdrm
14+
libGL
15+
expat
16+
xorg.libxcb
17+
libxkbcommon
18+
xorg.libX11
19+
xorg.libXcomposite
20+
xorg.libXdamage
21+
xorg.libXext
22+
xorg.libXfixes
23+
xorg.libXrandr
24+
mesa
25+
gtk3
26+
pango
27+
cairo
28+
alsa-lib
29+
dbus
30+
at-spi2-core
31+
cups
32+
xorg.libxshmfence
33+
udev
34+
libgbm
35+
]);
36+
debugBuild = false;
37+
buildType = if debugBuild then "Debug" else "Release";
38+
platform =
39+
{
40+
"aarch64-linux" = "linuxarm64";
41+
"x86_64-linux" = "linux64";
42+
}
43+
.${pkgs.stdenv.hostPlatform.system} or (throw "Unsupported system: ${pkgs.stdenv.hostPlatform.system}");
44+
arches =
45+
{
46+
"linuxarm64" = {
47+
depsArch = "arm64";
48+
projectArch = "arm64";
49+
targetArch = "arm64";
50+
};
51+
"linux64" = {
52+
depsArch = "amd64";
53+
projectArch = "x86_64";
54+
targetArch = "x86_64";
55+
};
56+
}
57+
.${platform};
58+
inherit (arches) depsArch projectArch targetArch;
59+
60+
in
61+
pkgs.stdenv.mkDerivation rec {
62+
pname = "jcef-ccbluex";
63+
rev = "06399a49d24f2c372668ccce26a15c533199ec9e";
64+
# This is the commit number
65+
# Currently from the branch: https://github.com/JetBrains/jcef/tree/242
66+
# Run `git rev-list --count HEAD`
67+
version = "867";
68+
69+
nativeBuildInputs = with pkgs; [
70+
cmake
71+
git
72+
jdk
73+
ninja
74+
python3
75+
bintools
76+
strip-nondeterminism
77+
];
78+
buildInputs = with pkgs; [
79+
boost
80+
xorg.libX11
81+
xorg.libXdamage
82+
nss
83+
nspr
84+
thrift
85+
];
86+
87+
#src = fetchFromGitHub {
88+
# owner = "CCBlueX";
89+
# repo = "java-cef";
90+
# inherit rev;
91+
# hash = "sha256-V/RlPp6a8ouVbUWwyPPU2hcsUlUXhVicc2yaPyi3GO0=";
92+
#};
93+
94+
src = ./.;
95+
cef-bin =
96+
let
97+
# `cef_binary_${CEF_VERSION}_linux64_minimal`, where CEF_VERSION is from $src/CMakeLists.txt
98+
name = "cef_binary_122.1.10+gc902316+chromium-122.0.6261.112_${platform}";
99+
hash =
100+
{
101+
"linux64" = "sha256-4EGKJgfRon4vkbwq14V5gSlph0Z5sjVnrzWv9nlQ20Q=";
102+
}
103+
.${platform};
104+
urlName = builtins.replaceStrings [ "+" ] [ "%2B" ] name;
105+
in
106+
pkgs.fetchzip {
107+
url = "https://cef-builds.spotifycdn.com/${urlName}.tar.bz2";
108+
inherit name hash;
109+
};
110+
# Find the hash in tools/buildtools/linux64/clang-format.sha1
111+
clang-fmt = pkgs.fetchurl {
112+
url = "https://storage.googleapis.com/chromium-clang-format/dd736afb28430c9782750fc0fd5f0ed497399263";
113+
hash = "sha256-4H6FVO9jdZtxH40CSfS+4VESAHgYgYxfCBFSMHdT0hE=";
114+
};
115+
releaseName = {
116+
"linux64" = "linux_amd64";
117+
}.${platform};
118+
119+
configurePhase = ''
120+
runHook preConfigure
121+
122+
patchShebangs .
123+
124+
cp -r ${cef-bin} third_party/cef/${cef-bin.name}
125+
chmod +w -R third_party/cef/${cef-bin.name}
126+
patchelf third_party/cef/${cef-bin.name}/${buildType}/libcef.so --set-rpath "${rpath}" --add-needed libudev.so
127+
patchelf third_party/cef/${cef-bin.name}/${buildType}/libGLESv2.so --set-rpath "${rpath}" --add-needed libGL.so.1
128+
patchelf third_party/cef/${cef-bin.name}/${buildType}/chrome-sandbox --set-interpreter $(cat $NIX_BINTOOLS/nix-support/dynamic-linker)
129+
sed 's/-O0/-O2/' -i third_party/cef/${cef-bin.name}/cmake/cef_variables.cmake
130+
131+
sed \
132+
-e 's|os.path.isdir(os.path.join(path, \x27.git\x27))|True|' \
133+
-e 's|"%s rev-parse %s" % (git_exe, branch)|"echo '${rev}'"|' \
134+
-e 's|"%s config --get remote.origin.url" % git_exe|"echo 'https://github.com/jetbrains/jcef'"|' \
135+
-e 's|"%s rev-list --count %s" % (git_exe, branch)|"echo '${version}'"|' \
136+
-i tools/git_util.py
137+
138+
cp ${clang-fmt} tools/buildtools/linux64/clang-format
139+
chmod +w tools/buildtools/linux64/clang-format
140+
141+
sed \
142+
-e 's|include(cmake/vcpkg.cmake)||' \
143+
-e 's|bring_vcpkg()||' \
144+
-e 's|vcpkg_install_package(boost-filesystem boost-interprocess thrift)||' \
145+
-i CMakeLists.txt
146+
147+
mkdir jcef_build
148+
cd jcef_build
149+
150+
cmake -G "Ninja" -DPROJECT_ARCH="${projectArch}" -DCMAKE_BUILD_TYPE=${buildType} ..
151+
152+
runHook postConfigure
153+
'';
154+
155+
installPhase = ''
156+
export JCEF_ROOT_DIR=$(realpath ..)
157+
export OUT_NATIVE_DIR=$JCEF_ROOT_DIR/jcef_build/native/${buildType}
158+
strip $OUT_NATIVE_DIR/libcef.so
159+
strip-nondeterminism $OUT_NATIVE_DIR/libcef.so
160+
mkdir -p $out/
161+
cp -R "$OUT_NATIVE_DIR"/* $out/
162+
'';
163+
164+
postBuild = ''
165+
export JCEF_ROOT_DIR=$(realpath ..)
166+
'';
167+
fixupPhase = ''
168+
export JCEF_ROOT_DIR=$(realpath ..)
169+
'';
170+
171+
172+
dontStrip = debugBuild;
173+
174+
meta = {
175+
description = "CCBlueX' fork of JCEF";
176+
license = pkgs.lib.licenses.bsd3;
177+
homepage = "https://github.com/CCBlueX/java-cef";
178+
};
179+
}

0 commit comments

Comments
 (0)