about summary refs log tree commit diff
path: root/pkgs/by-name/yo
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/by-name/yo')
-rw-r--r--pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation16
-rw-r--r--pkgs/by-name/yo/yourkit-java/package.nix95
-rwxr-xr-xpkgs/by-name/yo/yourkit-java/update.sh54
3 files changed, 165 insertions, 0 deletions
diff --git a/pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation b/pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation
new file mode 100644
index 0000000000000..df068b97d1944
--- /dev/null
+++ b/pkgs/by-name/yo/yourkit-java/forbid-desktop-item-creation
@@ -0,0 +1,16 @@
+CONFIG_DIR=$YS/config
+if [ ! -d $CONFIG_DIR ]; then
+    mkdir -p $CONFIG_DIR
+fi
+
+REGISTRY=$CONFIG_DIR/registry8.xml
+if [ ! -e $REGISTRY ]; then
+    cat >$REGISTRY <<EOF
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<registry8>
+  <desktop-file.created>
+    <boolean value="true"/>
+  </desktop-file.created>
+</registry8>
+EOF
+fi
diff --git a/pkgs/by-name/yo/yourkit-java/package.nix b/pkgs/by-name/yo/yourkit-java/package.nix
new file mode 100644
index 0000000000000..b2d5451a93131
--- /dev/null
+++ b/pkgs/by-name/yo/yourkit-java/package.nix
@@ -0,0 +1,95 @@
+{ fetchzip
+, lib
+, stdenvNoCC
+, copyDesktopItems
+, imagemagick
+, makeDesktopItem
+, jre
+}:
+let
+  vPath = v: lib.elemAt (lib.splitString "-" v) 0;
+
+  version = "2024.3-b157";
+
+  arches = {
+    aarch64-linux = "arm64";
+    x86_64-linux = "x64";
+  };
+
+  arch =
+    arches.${stdenvNoCC.targetPlatform.system} or (throw "Unsupported system");
+
+  hashes = {
+    arm64 = "sha256-0a9maZhgtXH21Ph0o3Rb+rCPhAmZRxjZCRyDmTvusLk=";
+    x64 = "sha256-nLaOOkPG2QEHkHd0S2AYLT2IpkMchGw9adyUDLCNQFg=";
+  };
+
+  desktopItem = makeDesktopItem {
+    name = "YourKit Java Profiler";
+    desktopName = "YourKit Java Profiler " + version;
+    type = "Application";
+    exec = "yourkit-java-profiler %f";
+    icon = "yourkit-java-profiler";
+    categories = [ "Development" "Java" "Profiling" ];
+    terminal = false;
+    startupWMClass = "YourKit Java Profiler";
+  };
+in
+stdenvNoCC.mkDerivation {
+  inherit version;
+
+  pname = "yourkit-java";
+
+  src = fetchzip {
+    url = "https://download.yourkit.com/yjp/${vPath version}/YourKit-JavaProfiler-${version}-${arch}.zip";
+    hash = hashes.${arch};
+  };
+
+  nativeBuildInputs = [ copyDesktopItems imagemagick ];
+
+  buildInputs = [ jre ];
+
+  desktopItems = [ desktopItem ];
+
+  installPhase = ''
+    runHook preInstall
+
+    mkdir -p $out
+    cp -pr bin lib license.html license-redist.txt probes samples $out
+    cp ${./forbid-desktop-item-creation} $out/bin/forbid-desktop-item-creation
+    mv $out/bin/profiler.sh $out/bin/yourkit-java-profiler
+    mkdir -p $out/share/icons
+    convert $out/bin/profiler.ico\[0] \
+            -size 256x256 \
+            $out/share/icons/yourkit-java-profiler.png
+    rm $out/bin/profiler.ico
+    rm -rf $out/bin/{windows-*,mac,linux-{*-32,musl-*,ppc-*}}
+    if [[ ${arch} = x64 ]]; then
+      rm -rf $out/bin/linux-arm-64
+    else
+      rm -rf $out/bin/linux-x86-64
+    fi
+    substituteInPlace $out/bin/yourkit-java-profiler \
+        --replace 'JAVA_EXE="$YD/jre64/bin/java"' JAVA_EXE=${jre}/bin/java
+    # Use our desktop item, which will be purged when this package
+    # gets removed
+    sed -i -e "/^YD=/isource $out/bin/forbid-desktop-item-creation\\
+        " \
+        $out/bin/yourkit-java-profiler
+
+    runHook postInstall
+  '';
+
+  passthru.updateScript = ./update.sh;
+
+  meta = with lib; {
+    description = "Award winning, fully featured low overhead profiler for Java EE and Java SE platforms";
+    homepage = "https://www.yourkit.com";
+    changelog = "https://www.yourkit.com/changes/";
+    license = licenses.unfree;
+    mainProgram = "yourkit-java-profiler";
+    platforms = attrNames arches;
+    sourceProvenance = with sourceTypes; [ binaryBytecode ];
+    maintainers = with maintainers; [ herberteuler ];
+  };
+}
diff --git a/pkgs/by-name/yo/yourkit-java/update.sh b/pkgs/by-name/yo/yourkit-java/update.sh
new file mode 100755
index 0000000000000..0b95732f6b74a
--- /dev/null
+++ b/pkgs/by-name/yo/yourkit-java/update.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env nix-shell
+#!nix-shell -i bash -p coreutils curl gawk gnused nix-prefetch
+
+set -euo pipefail
+
+ROOT="$(dirname "$(readlink -f "$0")")"
+DRV_BASE=package.nix
+NIX_DRV="$ROOT/$DRV_BASE"
+if [[ ! -f "$NIX_DRV" ]]; then
+  echo "ERROR: cannot find $DRV_BASE in $ROOT"
+  exit 1
+fi
+
+function retrieve_latest_version () {
+    curl https://www.yourkit.com/java/profiler/download/ \
+        | grep -Eo '(Version|Build): ([a-z0-9#.-])+' \
+        | awk '{ print $2 }' \
+        | tr -d '\n' \
+        | sed 's/#/-b/'
+}
+
+function calc_hash () {
+    local version=$1
+    local url=$2
+    nix-prefetch --option extra-experimental-features flakes \
+                 "{ stdenv, fetchzip }:
+stdenv.mkDerivation {
+  pname = \"yourkit-java-binary\";
+  version = \"$version\";
+  src = fetchzip {
+    url = \"$url\";
+  };
+}"
+}
+
+function update_hash () {
+    local arch=$1
+    local version=$2
+    local date=$(echo $version | sed 's/-.*//')
+    local url=https://download.yourkit.com/yjp/$date/YourKit-JavaProfiler-$version-$arch.zip
+    local hash=$(calc_hash $version $url)
+    sed -i -e "s|^.*$arch.*=.*\"sha256-.*$|    $arch = \"$hash\";|" $NIX_DRV
+}
+
+version=$(retrieve_latest_version)
+sed -i -e "s|^.*version.*=.*\".*$|  version = \"$version\";|" $NIX_DRV
+for arch in arm64 x64; do
+    update_hash $arch $version
+done
+
+# Local variables:
+# mode: shell-script
+# eval: (sh-set-shell "bash")
+# End: