at master 5.8 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 jetbrains, 6 jdk, 7 git, 8 autoconf, 9 unzip, 10 rsync, 11 debugBuild ? false, 12 withJcef ? true, 13 14 libXdamage, 15 libXxf86vm, 16 libXrandr, 17 libXi, 18 libXcursor, 19 libXrender, 20 libX11, 21 libXext, 22 libxkbcommon, 23 libxcb, 24 nss, 25 nspr, 26 libdrm, 27 libgbm, 28 wayland, 29 udev, 30 fontconfig, 31 shaderc, 32 vulkan-headers, 33}: 34 35assert debugBuild -> withJcef; 36 37let 38 arch = 39 { 40 "aarch64-linux" = "aarch64"; 41 "x86_64-linux" = "x64"; 42 } 43 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); 44 cpu = stdenv.hostPlatform.parsed.cpu.name; 45in 46jdk.overrideAttrs (oldAttrs: rec { 47 pname = "jetbrains-jdk" + lib.optionalString withJcef "-jcef"; 48 javaVersion = "21.0.7"; 49 build = "1038.58"; 50 # To get the new tag: 51 # git clone https://github.com/jetbrains/jetbrainsruntime 52 # cd jetbrainsruntime 53 # git tag --points-at [revision] 54 # Look for the line that starts with jbr- 55 openjdkTag = "jbr-release-21.0.7b1038.58"; 56 version = "${javaVersion}-b${build}"; 57 58 src = fetchFromGitHub { 59 owner = "JetBrains"; 60 repo = "JetBrainsRuntime"; 61 rev = "jb${version}"; 62 hash = "sha256-sGAMrE9gAt73jgLlNW8p5Lz37gFiK4ZvMQ8giE2Ia54="; 63 }; 64 65 env = { 66 BOOT_JDK = jdk.home; 67 # run `git log -1 --pretty=%ct` in jdk repo for new value on update 68 SOURCE_DATE_EPOCH = 1745907200; 69 }; 70 71 patches = [ ]; 72 73 dontConfigure = true; 74 75 buildPhase = '' 76 runHook preBuild 77 78 ${lib.optionalString withJcef "cp -r ${jetbrains.jcef} jcef_linux_${arch}"} 79 80 sed \ 81 -e "s/OPENJDK_TAG=.*/OPENJDK_TAG=${openjdkTag}/" \ 82 -e "s/SOURCE_DATE_EPOCH=.*//" \ 83 -e "s/export SOURCE_DATE_EPOCH//" \ 84 -i jb/project/tools/common/scripts/common.sh 85 declare -a realConfigureFlags 86 for configureFlag in "''${configureFlags[@]}"; do 87 case "$configureFlag" in 88 --host=*) 89 # intentionally omit flag 90 ;; 91 *) 92 realConfigureFlags+=("$configureFlag") 93 ;; 94 esac 95 done 96 echo "computed configure flags: ''${realConfigureFlags[*]}" 97 substituteInPlace jb/project/tools/linux/scripts/mkimages_${arch}.sh --replace-fail "STATIC_CONF_ARGS" "STATIC_CONF_ARGS ''${realConfigureFlags[*]}" 98 sed \ 99 -e "s/create_image_bundle \"jb/#/" \ 100 -e "s/echo Creating /exit 0 #/" \ 101 -i jb/project/tools/linux/scripts/mkimages_${arch}.sh 102 103 patchShebangs . 104 ./jb/project/tools/linux/scripts/mkimages_${arch}.sh ${build} ${ 105 if debugBuild then "fd" else (if withJcef then "jcef" else "nomod") 106 } 107 108 runHook postBuild 109 ''; 110 111 installPhase = 112 let 113 buildType = if debugBuild then "fastdebug" else "release"; 114 debugSuffix = if debugBuild then "-fastdebug" else ""; 115 jcefSuffix = if debugBuild || !withJcef then "" else "_jcef"; 116 jbrsdkDir = "jbrsdk${jcefSuffix}-${javaVersion}-linux-${arch}${debugSuffix}-b${build}"; 117 in 118 '' 119 runHook preInstall 120 121 mv build/linux-${cpu}-server-${buildType}/images/jdk/man build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir} 122 rm -rf build/linux-${cpu}-server-${buildType}/images/jdk 123 mv build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir} build/linux-${cpu}-server-${buildType}/images/jdk 124 '' 125 + oldAttrs.installPhase 126 + "runHook postInstall"; 127 128 postInstall = lib.optionalString withJcef '' 129 chmod +x $out/lib/openjdk/lib/chrome-sandbox 130 ''; 131 132 dontStrip = debugBuild; 133 134 postFixup = '' 135 # Build the set of output library directories to rpath against 136 LIBDIRS="${ 137 lib.makeLibraryPath [ 138 libXdamage 139 libXxf86vm 140 libXrandr 141 libXi 142 libXcursor 143 libXrender 144 libX11 145 libXext 146 libxkbcommon 147 libxcb 148 nss 149 nspr 150 libdrm 151 libgbm 152 wayland 153 udev 154 fontconfig 155 ] 156 }" 157 for output in ${lib.concatStringsSep " " oldAttrs.outputs}; do 158 if [ "$output" = debug ]; then continue; fi 159 LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS" 160 done 161 # Add the local library paths to remove dependencies on the bootstrap 162 for output in ${lib.concatStringsSep " " oldAttrs.outputs}; do 163 if [ "$output" = debug ]; then continue; fi 164 OUTPUTDIR=$(eval echo \$$output) 165 BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*) 166 echo "$BINLIBS" | while read i; do 167 patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true 168 done 169 done 170 ''; 171 172 nativeBuildInputs = [ 173 git 174 autoconf 175 unzip 176 rsync 177 shaderc # glslc 178 ] 179 ++ oldAttrs.nativeBuildInputs; 180 181 buildInputs = [ 182 vulkan-headers 183 ] 184 ++ oldAttrs.buildInputs or [ ]; 185 186 meta = with lib; { 187 description = "OpenJDK fork to better support Jetbrains's products"; 188 longDescription = '' 189 JetBrains Runtime is a runtime environment for running IntelliJ Platform 190 based products on Windows, Mac OS X, and Linux. JetBrains Runtime is 191 based on OpenJDK project with some modifications. These modifications 192 include: Subpixel Anti-Aliasing, enhanced font rendering on Linux, HiDPI 193 support, ligatures, some fixes for native crashes not presented in 194 official build, and other small enhancements. 195 JetBrains Runtime is not a certified build of OpenJDK. Please, use at 196 your own risk. 197 ''; 198 homepage = "https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime"; 199 inherit (jdk.meta) license platforms mainProgram; 200 maintainers = with maintainers; [ 201 edwtjo 202 aoli-al 203 ]; 204 205 broken = stdenv.hostPlatform.isDarwin; 206 }; 207 208 passthru = oldAttrs.passthru // { 209 home = "${jetbrains.jdk}/lib/openjdk"; 210 }; 211})