From 1b111841756a353e860e8462fd9e4a7094d8815c Mon Sep 17 00:00:00 2001 From: GenericNerdyUsername Date: Tue, 1 Aug 2023 18:40:49 +0100 Subject: jetbrains.*: allow overriding of the `vmopts` file --- pkgs/applications/editors/jetbrains/linux.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pkgs/applications/editors/jetbrains/linux.nix') diff --git a/pkgs/applications/editors/jetbrains/linux.nix b/pkgs/applications/editors/jetbrains/linux.nix index efc939d0324..307481e5894 100644 --- a/pkgs/applications/editors/jetbrains/linux.nix +++ b/pkgs/applications/editors/jetbrains/linux.nix @@ -115,8 +115,8 @@ with stdenv; lib.makeOverridable mkDerivation (rec { --set-default ANDROID_JAVA_HOME "$jdk" \ --set-default JAVA_HOME "$jdk" \ --set-default JETBRAINSCLIENT_JDK "$jdk" \ - --set ${hiName}_JDK "$jdk" \ - --set ${hiName}_VM_OPTIONS ${vmoptsFile} + --set-default ${hiName}_JDK "$jdk" \ + --set-default ${hiName}_VM_OPTIONS ${vmoptsFile} ln -s "$out/$pname/bin/${loName}.sh" $out/bin/$pname echo -e '#!/usr/bin/env bash\n'"$out/$pname/bin/remote-dev-server.sh"' "$@"' > $out/$pname/bin/remote-dev-server-wrapped.sh -- cgit 1.4.1 From bee39a0151af0c29fc934e9c21fdcd52094ff462 Mon Sep 17 00:00:00 2001 From: Pavel Anpin Date: Mon, 14 Aug 2023 16:09:39 +0400 Subject: jetbrains added udev to extraLdPath --- pkgs/applications/editors/jetbrains/linux.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'pkgs/applications/editors/jetbrains/linux.nix') diff --git a/pkgs/applications/editors/jetbrains/linux.nix b/pkgs/applications/editors/jetbrains/linux.nix index efc939d0324..2d6cbf5b872 100644 --- a/pkgs/applications/editors/jetbrains/linux.nix +++ b/pkgs/applications/editors/jetbrains/linux.nix @@ -11,6 +11,7 @@ , unzip , libsecret , libnotify +, udev , e2fsprogs , python3 , vmopts ? null @@ -109,6 +110,9 @@ with stdenv; lib.makeOverridable mkDerivation (rec { # Some internals want libstdc++.so.6 stdenv.cc.cc.lib libsecret e2fsprogs libnotify + # Required for Help -> Collect Logs + # in at least rider and goland + udev ] ++ extraLdPath)}" \ ${lib.concatStringsSep " " extraWrapperArgs} \ --set-default JDK_HOME "$jdk" \ -- cgit 1.4.1 From 8ff6850f2564d26a91b30eb8f7993a7a2c3bf4bb Mon Sep 17 00:00:00 2001 From: nixdrin <146267602+nixdrin@users.noreply.github.com> Date: Thu, 28 Sep 2023 21:03:14 +0200 Subject: jetbrains: drop libstdc++.so.6 from LD_LIBRARY_PATH Most of the libraries listed in the LD_LIBRARY_PATH for the Jetbrains IDEs are loaded indirectly using JNA in Java code, e.g. myLibNotify = Native.load("libnotify.so.4", LibNotify.class); [1] private val library = Native.load("secret-1", SecretLibrary::class.java) [2] In this case the typical patching mechanism with Nix does not work because JNA does the library lookup at runtime with its own mechanism. However, there is one outlier: stdenv.cc.cc.lib is also added to the LD_LIBRARY_PATH for libstdc++.so.6 because it is reportedly needed for some "internals". It does not make sense to access libstdc++ from Java code so it feels like this one was added to work around some native library or executable that should be patched instead of using LD_LIBRARY_PATH. Unfortunately, having libstdc++ in LD_LIBRARY_PATH can also easily cause ABI conflicts. This is because this variable is inherited into terminals opened within the IDE. Using a Nix environment there with different versions of libstdc++ easily causes errors such as libstdc++.so.6: version `GLIBCXX_3.4.29' not found Most of the IDEs work just fine without having libstdc++ in LD_LIBRARY_PATH. Since it's not really clear why it has to be in there let's just drop it to avoid the ABI conflicts. [1]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java#L40 [2]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/credential-store/src/linuxSecretLibrary.kt#L38 --- pkgs/applications/editors/jetbrains/linux.nix | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'pkgs/applications/editors/jetbrains/linux.nix') diff --git a/pkgs/applications/editors/jetbrains/linux.nix b/pkgs/applications/editors/jetbrains/linux.nix index 2d6cbf5b872..cbbde3590c1 100644 --- a/pkgs/applications/editors/jetbrains/linux.nix +++ b/pkgs/applications/editors/jetbrains/linux.nix @@ -107,9 +107,7 @@ with stdenv; lib.makeOverridable mkDerivation (rec { wrapProgram "$out/$pname/bin/${loName}.sh" \ --prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git python3 ]}" \ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([ - # Some internals want libstdc++.so.6 - stdenv.cc.cc.lib libsecret e2fsprogs - libnotify + libsecret e2fsprogs libnotify # Required for Help -> Collect Logs # in at least rider and goland udev -- cgit 1.4.1 From 7a8b142607999eb082a5fb9be5ec75d2cdedc50e Mon Sep 17 00:00:00 2001 From: nixdrin <146267602+nixdrin@users.noreply.github.com> Date: Thu, 28 Sep 2023 20:04:03 +0200 Subject: jetbrains: use -Djna.libary.path instead of LD_LIBRARY_PATH Most of the libraries listed in the LD_LIBRARY_PATH for the Jetbrains IDEs are loaded indirectly using JNA in Java code, e.g. myLibNotify = Native.load("libnotify.so.4", LibNotify.class); [1] private val library = Native.load("secret-1", SecretLibrary::class.java) [2] In this case the typical patching mechanism with Nix does not work because JNA does the library lookup at runtime with its own mechanism. However, to avoid causing ABI conflicts when using Nix in the terminal of the IDE it's better to avoid using LD_LIBRARY_PATH. JNA also looks for a "jna.library.path" Java system property when looking for libraries. Generate that property with the needed paths instead and append it to the vmopts file so that the property is applied when starting the IDE. With this the libraries only become available for the IDE and do not leak into terminals opened within the IDE context. [1]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/platform-impl/src/com/intellij/ui/LibNotifyWrapper.java#L40 [2]: https://github.com/JetBrains/intellij-community/blob/c0a703267a671bbbac2384fc226c82b2203db72b/platform/credential-store/src/linuxSecretLibrary.kt#L38 --- pkgs/applications/editors/jetbrains/linux.nix | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'pkgs/applications/editors/jetbrains/linux.nix') diff --git a/pkgs/applications/editors/jetbrains/linux.nix b/pkgs/applications/editors/jetbrains/linux.nix index cbbde3590c1..c5490e01b51 100644 --- a/pkgs/applications/editors/jetbrains/linux.nix +++ b/pkgs/applications/editors/jetbrains/linux.nix @@ -89,6 +89,21 @@ with stdenv; lib.makeOverridable mkDerivation (rec { if [ -d "plugins/remote-dev-server" ]; then patch -p1 < ${./JetbrainsRemoteDev.patch} fi + + vmopts_file=bin/linux/${vmoptsName} + if [[ ! -f $vmopts_file ]]; then + vmopts_file=bin/${vmoptsName} + if [[ ! -f $vmopts_file ]]; then + echo "ERROR: $vmopts_file not found" + exit 1 + fi + fi + echo -Djna.library.path=${lib.makeLibraryPath ([ + libsecret e2fsprogs libnotify + # Required for Help -> Collect Logs + # in at least rider and goland + udev + ])} >> $vmopts_file ''; installPhase = '' @@ -106,12 +121,7 @@ with stdenv; lib.makeOverridable mkDerivation (rec { wrapProgram "$out/$pname/bin/${loName}.sh" \ --prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git python3 ]}" \ - --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([ - libsecret e2fsprogs libnotify - # Required for Help -> Collect Logs - # in at least rider and goland - udev - ] ++ extraLdPath)}" \ + --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath extraLdPath}" \ ${lib.concatStringsSep " " extraWrapperArgs} \ --set-default JDK_HOME "$jdk" \ --set-default ANDROID_JAVA_HOME "$jdk" \ -- cgit 1.4.1