summary refs log tree commit diff
path: root/pkgs/applications/editors/jetbrains/common.nix
diff options
context:
space:
mode:
authorVasiliy Solovey <miltador@yandex.ua>2017-04-01 10:21:19 +0300
committerVasiliy Solovey <miltador@yandex.ua>2017-04-01 10:21:19 +0300
commitbab0ed75c0207fde57ca80bcf0983ba2e32e1271 (patch)
tree91c5241111022ea2c1a31400bcc3b2b5afe8ddef /pkgs/applications/editors/jetbrains/common.nix
parentff1d0ce4385641c473f999c2d0c5e70e6dd8b781 (diff)
downloadnixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar.gz
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar.bz2
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar.lz
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar.xz
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.tar.zst
nixlib-bab0ed75c0207fde57ca80bcf0983ba2e32e1271.zip
idea: rename to jetbrains
JetBrains IDEs were put under wrong scope which was confusing.
Fixes #24453
Diffstat (limited to 'pkgs/applications/editors/jetbrains/common.nix')
-rw-r--r--pkgs/applications/editors/jetbrains/common.nix74
1 files changed, 74 insertions, 0 deletions
diff --git a/pkgs/applications/editors/jetbrains/common.nix b/pkgs/applications/editors/jetbrains/common.nix
new file mode 100644
index 000000000000..839f537843d0
--- /dev/null
+++ b/pkgs/applications/editors/jetbrains/common.nix
@@ -0,0 +1,74 @@
+{ stdenv, fetchurl, makeDesktopItem, makeWrapper, patchelf, p7zip
+, coreutils, gnugrep, which, git, python, unzip }:
+
+{ name, product, version, src, wmClass, jdk, meta } @ attrs:
+
+with stdenv.lib;
+
+let loName = toLower product;
+    hiName = toUpper product;
+    execName = concatStringsSep "-" (init (splitString "-" name));
+in
+
+with stdenv; lib.makeOverridable mkDerivation rec {
+  inherit name src meta;
+  desktopItem = makeDesktopItem {
+    name = execName;
+    exec = execName;
+    comment = lib.replaceChars ["\n"] [" "] meta.longDescription;
+    desktopName = product;
+    genericName = meta.description;
+    categories = "Application;Development;";
+    icon = execName;
+    extraEntries = ''
+      StartupWMClass=${wmClass}
+    '';
+  };
+
+  buildInputs = [ makeWrapper patchelf p7zip unzip ];
+
+  patchPhase = ''
+      get_file_size() {
+        local fname="$1"
+        echo $(ls -l $fname | cut -d ' ' -f5)
+      }
+
+      munge_size_hack() {
+        local fname="$1"
+        local size="$2"
+        strip $fname
+        truncate --size=$size $fname
+      }
+
+      interpreter=$(echo ${stdenv.glibc.out}/lib/ld-linux*.so.2)
+      if [ "${stdenv.system}" == "x86_64-linux" ]; then
+        target_size=$(get_file_size bin/fsnotifier64)
+        patchelf --set-interpreter "$interpreter" bin/fsnotifier64
+        munge_size_hack bin/fsnotifier64 $target_size
+      else
+        target_size=$(get_file_size bin/fsnotifier)
+        patchelf --set-interpreter "$interpreter" bin/fsnotifier
+        munge_size_hack bin/fsnotifier $target_size
+      fi
+  '';
+
+  installPhase = ''
+    mkdir -p $out/{bin,$name,share/pixmaps,libexec/${name}}
+    cp -a . $out/$name
+    ln -s $out/$name/bin/${loName}.png $out/share/pixmaps/${execName}.png
+    mv bin/fsnotifier* $out/libexec/${name}/.
+
+    jdk=${jdk.home}
+    item=${desktopItem}
+
+    makeWrapper "$out/$name/bin/${loName}.sh" "$out/bin/${execName}" \
+      --prefix PATH : "$out/libexec/${name}:${stdenv.lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
+      --set JDK_HOME "$jdk" \
+      --set ${hiName}_JDK "$jdk" \
+      --set ANDROID_JAVA_HOME "$jdk" \
+      --set JAVA_HOME "$jdk"
+
+    ln -s "$item/share/applications" $out/share
+  '';
+
+}