From 714eca6967a0017b3228966871a9a3803ab3effb Mon Sep 17 00:00:00 2001 From: taku0 Date: Sun, 20 Dec 2020 15:22:31 +0900 Subject: [PATCH] adoptopenjdk-bin: add support for GTK+ Look and Feel --- .../adoptopenjdk-bin/jdk-linux-base.nix | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix index 0fcad6c333f8..1c5fd67f2d95 100644 --- a/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix +++ b/pkgs/development/compilers/adoptopenjdk-bin/jdk-linux-base.nix @@ -4,16 +4,31 @@ sourcePerArch: , lib , fetchurl , autoPatchelfHook +, makeWrapper +# minimum dependencies , alsaLib -, freetype , fontconfig -, zlib -, xorg +, freetype , libffi +, xorg +, zlib +# runtime dependencies +, cups +# runtime dependencies for GTK+ Look and Feel +, gtkSupport ? true +, cairo +, glib +, gtk3 }: let cpuName = stdenv.hostPlatform.parsed.cpu.name; + runtimeDependencies = [ + cups + ] ++ lib.optionals gtkSupport [ + cairo glib gtk3 + ]; + runtimeLibraryPath = lib.makeLibraryPath runtimeDependencies; in let result = stdenv.mkDerivation rec { @@ -28,11 +43,19 @@ let result = stdenv.mkDerivation rec { }; buildInputs = [ - alsaLib freetype fontconfig zlib xorg.libX11 xorg.libXext xorg.libXtst - xorg.libXi xorg.libXrender stdenv.cc.cc.lib + alsaLib # libasound.so wanted by lib/libjsound.so + fontconfig + freetype + stdenv.cc.cc.lib # libstdc++.so.6 + xorg.libX11 + xorg.libXext + xorg.libXi + xorg.libXrender + xorg.libXtst + zlib ] ++ lib.optional stdenv.isAarch32 libffi; - nativeBuildInputs = [ autoPatchelfHook ]; + nativeBuildInputs = [ autoPatchelfHook makeWrapper ]; # See: https://github.com/NixOS/patchelf/issues/10 dontStrip = 1; @@ -57,6 +80,13 @@ let result = stdenv.mkDerivation rec { cat <> "$out/nix-support/setup-hook" if [ -z "\''${JAVA_HOME-}" ]; then export JAVA_HOME=$out; fi EOF + + # We cannot use -exec since wrapProgram is a function but not a command. + for bin in $( find "$out" -executable -type f ); do + if patchelf --print-interpreter "$bin" &> /dev/null; then + wrapProgram "$bin" --prefix LD_LIBRARY_PATH : "${runtimeLibraryPath}" + fi + done ''; preFixup = ''