Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions pkgs/by-name/ce/cef-binary/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@
buildType ? "Release",
srcHashes ? {
aarch64-linux = "sha256-wUCXk5Nqgzu0q0PvV8a2AKF3h4YxxTeaP2yVecrf0j8=";
aarch64-darwin = "sha256-7vEhqsXSQtlZN3Ky0ZYo8vAlpeXAZAP4lgdFe90/UQA=";
x86_64-linux = "sha256-pFMHjj4MktjnX3g03sgLqgai4X/lF29Phmduf7a+KfM=";
#TODO: 26.11: remove the support for x86_64-darwin for more info please see: https://github.com/NixOS/nixpkgs/pull/492160
x86_64-darwin = "sha256-zYltcWgv56xo8PNfg17Ayp0+bdJUW18co1aze2ytry8=";
},
}:

Expand Down Expand Up @@ -76,15 +79,18 @@ let
attrs:
attrs.${stdenv.hostPlatform.system} or (throw "Unsupported system ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation {
stdenv.mkDerivation (finalAttrs: {
pname = "cef-binary";
inherit version;

src = fetchurl {
url = "https://cef-builds.spotifycdn.com/cef_binary_${version}+g${gitRevision}+chromium-${chromiumVersion}_${
selectSystem {
aarch64-linux = "linuxarm64";
aarch64-darwin = "macosarm64";
x86_64-linux = "linux64";
#TODO: 26.11: remove the support for x86_64-darwin for more info please see: https://github.com/NixOS/nixpkgs/pull/492160
x86_64-darwin = "macosx64";
}
}_minimal.tar.bz2";
hash = selectSystem srcHashes;
Expand All @@ -94,16 +100,24 @@ stdenv.mkDerivation {

dontPatchELF = true;

patchLibs =
if stdenv.hostPlatform.isLinux then
''
patchelf --set-rpath "${rpath}" --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${buildType}/chrome-sandbox
patchelf --add-needed libudev.so --set-rpath "${rpath}" ${buildType}/libcef.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libEGL.so
patchelf --add-needed libGL.so.1 --set-rpath "${gl_rpath}" ${buildType}/libGLESv2.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libvk_swiftshader.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libvulkan.so.1
''
else
"";

installPhase = ''
runHook preInstall

sed 's/-O0/-O2/' -i cmake/cef_variables.cmake
patchelf --set-rpath "${rpath}" --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" ${buildType}/chrome-sandbox
patchelf --add-needed libudev.so --set-rpath "${rpath}" ${buildType}/libcef.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libEGL.so
patchelf --add-needed libGL.so.1 --set-rpath "${gl_rpath}" ${buildType}/libGLESv2.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libvk_swiftshader.so
patchelf --set-rpath "${gl_rpath}" ${buildType}/libvulkan.so.1
${finalAttrs.patchLibs}
cp --recursive . $out

runHook postInstall
Expand All @@ -117,9 +131,12 @@ stdenv.mkDerivation {
meta = {
description = "Simple framework for embedding Chromium-based browsers in other applications";
homepage = "https://cef-builds.spotifycdn.com/index.html";
maintainers = with lib.maintainers; [ puffnfresh ];
maintainers = with lib.maintainers; [
puffnfresh
eveeifyeve # Darwin
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = lib.licenses.bsd3;
platforms = builtins.attrNames srcHashes;
};
}
})
134 changes: 96 additions & 38 deletions pkgs/development/compilers/jetbrains-jdk/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
fontconfig,
shaderc,
vulkan-headers,
darwin,
}:

assert debugBuild -> withJcef;
Expand All @@ -39,9 +40,13 @@ let
{
"aarch64-linux" = "aarch64";
"x86_64-linux" = "x64";
"aarch64-darwin" = "aarch64";
#TODO: 26.11: remove the support for x86_64-darwin for more info please see: https://github.com/NixOS/nixpkgs/pull/492160
"x86_64-darwin" = "x64";
}
.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
cpu = stdenv.hostPlatform.parsed.cpu.name;
os = if stdenv.isDarwin then "macosx" else "linux";
in
jdk.overrideAttrs (oldAttrs: rec {
pname = "jetbrains-jdk" + lib.optionalString withJcef "-jcef";
Expand Down Expand Up @@ -71,11 +76,31 @@ jdk.overrideAttrs (oldAttrs: rec {
patches = [ ];

dontConfigure = true;
jcefDestName = if stdenv.isDarwin then "jcef_mac" else "jcef_linux_${arch}";
mkimagesSh =
if stdenv.isDarwin then
"./jb/project/tools/mac/scripts/mkimages.sh"
else
"./jb/project/tools/linux/scripts/mkimages_${arch}.sh";

osSpecificPatch =
if stdenv.isDarwin then
''
sed -i '40i\--with-xcode-path="${darwin.xcode_16_1}" \\' ./jb/project/tools/mac/scripts/mkimages.sh
# See https://github.com/JetBrains/JetBrainsRuntime/issues/461
sed \
-e 's/C_O_FLAG_HIGHEST_JVM="-O3"/C_O_FLAG_HIGHEST_JVM="-O1"/g' \
-e 's/C_O_FLAG_HIGHEST="-O3"/C_O_FLAG_HIGHEST="-O1"/g' \
-e 's/C_O_FLAG_HI="-O3"/C_O_FLAG_HI="-O1"/g' \
-i make/autoconf/flags-cflags.m4
''
else
"";

buildPhase = ''
runHook preBuild

${lib.optionalString withJcef "cp -r ${jetbrains.jcef} jcef_linux_${arch}"}
${lib.optionalString withJcef "cp -r ${jetbrains.jcef} ${jcefDestName}"}

sed \
-e "s/OPENJDK_TAG=.*/OPENJDK_TAG=${openjdkTag}/" \
Expand All @@ -94,16 +119,14 @@ jdk.overrideAttrs (oldAttrs: rec {
esac
done
echo "computed configure flags: ''${realConfigureFlags[*]}"
substituteInPlace jb/project/tools/linux/scripts/mkimages_${arch}.sh --replace-fail "STATIC_CONF_ARGS" "STATIC_CONF_ARGS ''${realConfigureFlags[*]}"
substituteInPlace ${mkimagesSh} --replace-fail "STATIC_CONF_ARGS" "STATIC_CONF_ARGS ''${realConfigureFlags[*]}"
sed \
-e "s/create_image_bundle \"jb/#/" \
-e "s/echo Creating /exit 0 #/" \
-i jb/project/tools/linux/scripts/mkimages_${arch}.sh
-i ${mkimagesSh}

patchShebangs .
./jb/project/tools/linux/scripts/mkimages_${arch}.sh ${build} ${
if debugBuild then "fd" else (if withJcef then "jcef" else "nomod")
}
${mkimagesSh} ${build} ${if debugBuild then "fd" else (if withJcef then "jcef" else "nomod")}

runHook postBuild
'';
Expand All @@ -115,17 +138,39 @@ jdk.overrideAttrs (oldAttrs: rec {
jcefSuffix = if debugBuild || !withJcef then "" else "_jcef";
jbrsdkDir = "jbrsdk${jcefSuffix}-${javaVersion}-linux-${arch}${debugSuffix}-b${build}";
in
''
runHook preInstall

mv build/linux-${cpu}-server-${buildType}/images/jdk/man build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir}
rm -rf build/linux-${cpu}-server-${buildType}/images/jdk
mv build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir} build/linux-${cpu}-server-${buildType}/images/jdk
''
+ oldAttrs.installPhase
(
if stdenv.hostPlatform.isLinux then
''
runHook preInstall

mv build/${os}-${cpu}-server-${buildType}/images/jdk/man build/${os}-${cpu}-server-${buildType}/images/${jbrsdkDir}
rm -rf build/${os}-${cpu}-server-${buildType}/images/jdk
mv build/${os}-${cpu}-server-${buildType}/images/${jbrsdkDir} build/${os}-${cpu}-server-${buildType}/images/jdk
''
+ oldAttrs.installPhase
else
''
# We need to implement the install phase manually because the default jdk is zulu instead of OpenJDK.
mkdir -p $out/lib

cp -r build/${os}-${cpu}-server-${buildType}/images/jdk $out/lib/openjdk

# Remove some broken manpages.
rm -rf $out/lib/openjdk/man/ja*

# Mirror some stuff in top-level.
mkdir -p $out/share
ln -s $out/lib/openjdk/include $out/include
ln -s $out/lib/openjdk/man $out/share/man
ln -s $out/lib/openjdk/lib/src.zip $out/lib/src.zip
ln -s $out/include/linux/*_md.h $out/include/
ln -s $out/lib/openjdk/bin $out/bin
''
)
+ "runHook postInstall";

postInstall = lib.optionalString withJcef ''
# This is only available on Linux https://github.com/JetBrains/JetBrainsRuntime/releases/tag/jbr-release-21.0.6b631.42
postInstall = lib.optionalString (withJcef && stdenv.hostPlatform.isLinux) ''
chmod +x $out/lib/openjdk/lib/chrome-sandbox
'';

Expand All @@ -134,25 +179,29 @@ jdk.overrideAttrs (oldAttrs: rec {
postFixup = ''
# Build the set of output library directories to rpath against
LIBDIRS="${
lib.makeLibraryPath [
libxdamage
libxxf86vm
libxrandr
libxi
libxcursor
libxrender
libx11
libxext
libxkbcommon
libxcb
nss
nspr
libdrm
libgbm
wayland
udev
fontconfig
]
lib.makeLibraryPath (
[
libxdamage
libxxf86vm
libxrandr
libxi
libxcursor
libxrender
libx11
libxext
libxkbcommon
libxcb
nss
nspr
fontconfig
]
++ lib.optionals stdenv.isLinux [
wayland
libgbm
libdrm
udev
]
)
}"
for output in ${lib.concatStringsSep " " oldAttrs.outputs}; do
if [ "$output" = debug ]; then continue; fi
Expand All @@ -176,12 +225,22 @@ jdk.overrideAttrs (oldAttrs: rec {
rsync
shaderc # glslc
]
++ oldAttrs.nativeBuildInputs;
++ oldAttrs.nativeBuildInputs
++ lib.optionals stdenv.isDarwin [
darwin.bootstrap_cmds
darwin.xcode_16_1
darwin.xattr
];

buildInputs = [
vulkan-headers
]
++ oldAttrs.buildInputs or [ ];
++ oldAttrs.buildInputs or [ ]
++ lib.optionals stdenv.isDarwin [
darwin.bootstrap_cmds
darwin.xattr
darwin.xcode_16_1
];

meta = {
description = "OpenJDK fork to better support Jetbrains's products";
Expand All @@ -199,9 +258,8 @@ jdk.overrideAttrs (oldAttrs: rec {
inherit (jdk.meta) license platforms mainProgram;
maintainers = with lib.maintainers; [
aoli-al
eveeifyeve # Darwin
];

broken = stdenv.hostPlatform.isDarwin;
};

passthru = oldAttrs.passthru // {
Expand Down
Loading
Loading