traefik: add djds as maintainer (#377217)
[NixPkgs.git] / pkgs / development / compilers / jetbrains-jdk / 17.nix
blob8b0a0104b2f576baa7d13e6bee30e5a49054dd54
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   jetbrains,
6   openjdk17,
7   openjdk17-bootstrap,
8   git,
9   autoconf,
10   unzip,
11   rsync,
12   debugBuild ? false,
13   withJcef ? true,
15   libXdamage,
16   libXxf86vm,
17   libXrandr,
18   libXi,
19   libXcursor,
20   libXrender,
21   libX11,
22   libXext,
23   libxcb,
24   nss,
25   nspr,
26   libdrm,
27   libgbm,
28   wayland,
29   udev,
32 assert debugBuild -> withJcef;
34 let
35   arch =
36     {
37       "aarch64-linux" = "aarch64";
38       "x86_64-linux" = "x64";
39     }
40     .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
41   cpu = stdenv.hostPlatform.parsed.cpu.name;
43 openjdk17.overrideAttrs (oldAttrs: rec {
44   pname = "jetbrains-jdk" + lib.optionalString withJcef "-jcef";
45   javaVersion = "17.0.11";
46   build = "1207.24";
47   # To get the new tag:
48   # git clone https://github.com/jetbrains/jetbrainsruntime
49   # cd jetbrainsruntime
50   # git reset --hard [revision]
51   # git log --simplify-by-decoration --decorate=short --pretty=short | grep "jbr-" --color=never | cut -d "(" -f2 | cut -d ")" -f1 | awk '{print $2}' | sort -t "-" -k 2 -g | tail -n 1 | tr -d ","
52   openjdkTag = "jbr-17.0.8+7";
53   version = "${javaVersion}-b${build}";
55   src = fetchFromGitHub {
56     owner = "JetBrains";
57     repo = "JetBrainsRuntime";
58     rev = "jb${version}";
59     hash = "sha256-a7cJF2iCW/1GK0/GmVbaY5pYcn3YtZy5ngFkyAGRhu0=";
60   };
62   BOOT_JDK = openjdk17-bootstrap.home;
63   # run `git log -1 --pretty=%ct` in jdk repo for new value on update
64   SOURCE_DATE_EPOCH = 1715809405;
66   patches = [ ];
68   dontConfigure = true;
70   buildPhase = ''
71     runHook preBuild
73     ${lib.optionalString withJcef "cp -r ${jetbrains.jcef} jcef_linux_${arch}"}
75     sed \
76         -e "s/OPENJDK_TAG=.*/OPENJDK_TAG=${openjdkTag}/" \
77         -e "s/SOURCE_DATE_EPOCH=.*//" \
78         -e "s/export SOURCE_DATE_EPOCH//" \
79         -i jb/project/tools/common/scripts/common.sh
80     sed -i "s/STATIC_CONF_ARGS/STATIC_CONF_ARGS \$configureFlags/" jb/project/tools/linux/scripts/mkimages_${arch}.sh
81     sed \
82         -e "s/create_image_bundle \"jb/#/" \
83         -e "s/echo Creating /exit 0 #/" \
84         -i jb/project/tools/linux/scripts/mkimages_${arch}.sh
86     patchShebangs .
87     ./jb/project/tools/linux/scripts/mkimages_${arch}.sh ${build} ${
88       if debugBuild then "fd" else (if withJcef then "jcef" else "nomod")
89     }
91     runHook postBuild
92   '';
94   installPhase =
95     let
96       buildType = if debugBuild then "fastdebug" else "release";
97       debugSuffix = if debugBuild then "-fastdebug" else "";
98       jcefSuffix = if debugBuild || !withJcef then "" else "_jcef";
99       jbrsdkDir = "jbrsdk${jcefSuffix}-${javaVersion}-linux-${arch}${debugSuffix}-b${build}";
100     in
101     ''
102       runHook preInstall
104       mv build/linux-${cpu}-server-${buildType}/images/jdk/man build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir}
105       rm -rf build/linux-${cpu}-server-${buildType}/images/jdk
106       mv build/linux-${cpu}-server-${buildType}/images/${jbrsdkDir} build/linux-${cpu}-server-${buildType}/images/jdk
107     ''
108     + oldAttrs.installPhase
109     + "runHook postInstall";
111   postInstall = lib.optionalString withJcef ''
112     chmod +x $out/lib/openjdk/lib/chrome-sandbox
113   '';
115   dontStrip = debugBuild;
117   postFixup = ''
118     # Build the set of output library directories to rpath against
119     LIBDIRS="${
120       lib.makeLibraryPath [
121         libXdamage
122         libXxf86vm
123         libXrandr
124         libXi
125         libXcursor
126         libXrender
127         libX11
128         libXext
129         libxcb
130         nss
131         nspr
132         libdrm
133         libgbm
134         wayland
135         udev
136       ]
137     }"
138     for output in $outputs; do
139       if [ "$output" = debug ]; then continue; fi
140       LIBDIRS="$(find $(eval echo \$$output) -name \*.so\* -exec dirname {} \+ | sort -u | tr '\n' ':'):$LIBDIRS"
141     done
142     # Add the local library paths to remove dependencies on the bootstrap
143     for output in $outputs; do
144       if [ "$output" = debug ]; then continue; fi
145       OUTPUTDIR=$(eval echo \$$output)
146       BINLIBS=$(find $OUTPUTDIR/bin/ -type f; find $OUTPUTDIR -name \*.so\*)
147       echo "$BINLIBS" | while read i; do
148         patchelf --set-rpath "$LIBDIRS:$(patchelf --print-rpath "$i")" "$i" || true
149         patchelf --shrink-rpath "$i" || true
150       done
151     done
152   '';
154   nativeBuildInputs = [
155     git
156     autoconf
157     unzip
158     rsync
159   ] ++ oldAttrs.nativeBuildInputs;
161   meta = with lib; {
162     description = "An OpenJDK fork to better support Jetbrains's products.";
163     longDescription = ''
164       JetBrains Runtime is a runtime environment for running IntelliJ Platform
165       based products on Windows, Mac OS X, and Linux. JetBrains Runtime is
166       based on OpenJDK project with some modifications. These modifications
167       include: Subpixel Anti-Aliasing, enhanced font rendering on Linux, HiDPI
168       support, ligatures, some fixes for native crashes not presented in
169       official build, and other small enhancements.
170       JetBrains Runtime is not a certified build of OpenJDK. Please, use at
171       your own risk.
172     '';
173     homepage = "https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime";
174     inherit (openjdk17.meta) license platforms mainProgram;
175     maintainers = with maintainers; [ edwtjo ];
177     broken = stdenv.hostPlatform.isDarwin;
178   };
180   passthru = oldAttrs.passthru // {
181     home = "${jetbrains.jdk}/lib/openjdk";
182   };