From e3c8f10cbb58b225f2a5c96a49c6c2b745f6e38a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Edward=20Tj=C3=B6rnhammar?= Date: Sat, 19 Dec 2020 23:14:02 +0100 Subject: [PATCH] jetbrains: configurable vmoptions All products are now configurable through `config.jetbrains.vmoptions` Closes #107032 --- pkgs/applications/editors/jetbrains/common.nix | 13 +++++++++++-- pkgs/applications/editors/jetbrains/default.nix | 3 ++- pkgs/top-level/all-packages.nix | 1 + 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/editors/jetbrains/common.nix b/pkgs/applications/editors/jetbrains/common.nix index 07776bebe425..43dbd137f784 100644 --- a/pkgs/applications/editors/jetbrains/common.nix +++ b/pkgs/applications/editors/jetbrains/common.nix @@ -1,5 +1,6 @@ -{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf +{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf, writeText , coreutils, gnugrep, which, git, unzip, libsecret, libnotify +, vmopts ? null }: { name, product, version, src, wmClass, jdk, meta }: @@ -9,6 +10,11 @@ with stdenv.lib; let loName = toLower product; hiName = toUpper product; execName = concatStringsSep "-" (init (splitString "-" name)); + vmoptsName = loName + + ( if (with stdenv.hostPlatform; (is32bit || isDarwin)) + then "" + else "64" ) + + ".vmoptions"; in with stdenv; lib.makeOverridable mkDerivation rec { @@ -26,6 +32,8 @@ with stdenv; lib.makeOverridable mkDerivation rec { ''; }; + vmoptsFile = optionalString (vmopts != null) (writeText vmoptsName vmopts); + nativeBuildInputs = [ makeWrapper patchelf unzip ]; patchPhase = lib.optionalString (!stdenv.isDarwin) '' @@ -72,7 +80,8 @@ with stdenv; lib.makeOverridable mkDerivation rec { --set JDK_HOME "$jdk" \ --set ${hiName}_JDK "$jdk" \ --set ANDROID_JAVA_HOME "$jdk" \ - --set JAVA_HOME "$jdk" + --set JAVA_HOME "$jdk" \ + --set ${hiName}_VM_OPTIONS ${vmoptsFile} ln -s "$item/share/applications" $out/share ''; diff --git a/pkgs/applications/editors/jetbrains/default.nix b/pkgs/applications/editors/jetbrains/default.nix index 5348901bbfee..9638bea60c9a 100644 --- a/pkgs/applications/editors/jetbrains/default.nix +++ b/pkgs/applications/editors/jetbrains/default.nix @@ -2,12 +2,13 @@ , python , jdk, cmake, libxml2, zlib, python3, ncurses5 , dotnet-sdk_3 +, vmopts ? null }: with stdenv.lib; let - mkJetBrainsProduct = callPackage ./common.nix { }; + mkJetBrainsProduct = callPackage ./common.nix { inherit vmopts; }; # Sorted alphabetically buildClion = { name, version, src, license, description, wmClass, ... }: diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1d5766b7c656..4cdf4ec16500 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21648,6 +21648,7 @@ in }; jetbrains = (recurseIntoAttrs (callPackages ../applications/editors/jetbrains { + vmopts = config.jetbrains.vmopts or null; jdk = jetbrains.jdk; }) // { jdk = callPackage ../development/compilers/jetbrains-jdk { };