2023-07-15 17:15:38 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, makeDesktopItem
|
|
|
|
, makeWrapper
|
|
|
|
, patchelf
|
|
|
|
, writeText
|
|
|
|
, coreutils
|
|
|
|
, gnugrep
|
|
|
|
, which
|
|
|
|
, git
|
|
|
|
, unzip
|
|
|
|
, libsecret
|
|
|
|
, libnotify
|
|
|
|
, e2fsprogs
|
|
|
|
, python3
|
2020-12-25 13:55:36 +00:00
|
|
|
, vmopts ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
{ pname
|
|
|
|
, product
|
|
|
|
, productShort ? product
|
|
|
|
, version
|
|
|
|
, src
|
|
|
|
, wmClass
|
|
|
|
, buildNumber
|
|
|
|
, jdk
|
|
|
|
, meta
|
|
|
|
, extraLdPath ? [ ]
|
|
|
|
, extraWrapperArgs ? [ ]
|
|
|
|
}@args:
|
|
|
|
|
|
|
|
let
|
|
|
|
loName = lib.toLower productShort;
|
|
|
|
hiName = lib.toUpper productShort;
|
|
|
|
vmoptsName = loName
|
|
|
|
+ lib.optionalString stdenv.hostPlatform.is64bit "64"
|
|
|
|
+ ".vmoptions";
|
2020-04-24 23:36:52 +00:00
|
|
|
in
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
with stdenv; lib.makeOverridable mkDerivation (rec {
|
2022-03-30 09:31:56 +00:00
|
|
|
inherit pname version src;
|
2023-07-15 17:15:38 +00:00
|
|
|
passthru.buildNumber = buildNumber;
|
2022-03-30 09:31:56 +00:00
|
|
|
meta = args.meta // { mainProgram = pname; };
|
2021-06-28 23:13:55 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
2022-03-30 09:31:56 +00:00
|
|
|
name = pname;
|
|
|
|
exec = pname;
|
2023-07-15 17:15:38 +00:00
|
|
|
comment = lib.replaceStrings [ "\n" ] [ " " ] meta.longDescription;
|
2020-04-24 23:36:52 +00:00
|
|
|
desktopName = product;
|
|
|
|
genericName = meta.description;
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Development" ];
|
2022-03-30 09:31:56 +00:00
|
|
|
icon = pname;
|
2022-03-05 16:20:37 +00:00
|
|
|
startupWMClass = wmClass;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-02-02 18:25:31 +00:00
|
|
|
vmoptsFile = lib.optionalString (vmopts != null) (writeText vmoptsName vmopts);
|
2020-12-25 13:55:36 +00:00
|
|
|
|
2020-05-03 17:38:23 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper patchelf unzip ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
postPatch = ''
|
2023-07-15 17:15:38 +00:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
rm -rf jbr
|
|
|
|
# When using the IDE as a remote backend using gateway, it expects the jbr directory to contain the jdk
|
|
|
|
ln -s ${jdk.home} jbr
|
|
|
|
|
|
|
|
interpreter=$(echo ${stdenv.cc.libc}/lib/ld-linux*.so.2)
|
|
|
|
if [[ "${stdenv.hostPlatform.system}" == "x86_64-linux" && -e bin/fsnotifier64 ]]; 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
|
2023-08-04 22:07:22 +00:00
|
|
|
|
|
|
|
if [ -d "plugins/remote-dev-server" ]; then
|
|
|
|
patch -p1 < ${./JetbrainsRemoteDev.patch}
|
|
|
|
fi
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-07-14 22:03:04 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
mkdir -p $out/{bin,$pname,share/pixmaps,libexec/${pname},share/icons/hicolor/scalable/apps}
|
2022-03-30 09:31:56 +00:00
|
|
|
cp -a . $out/$pname
|
2022-11-27 09:42:12 +00:00
|
|
|
[[ -f $out/$pname/bin/${loName}.png ]] && ln -s $out/$pname/bin/${loName}.png $out/share/pixmaps/${pname}.png
|
2023-07-15 17:15:38 +00:00
|
|
|
[[ -f $out/$pname/bin/${loName}.svg ]] && ln -s $out/$pname/bin/${loName}.svg $out/share/pixmaps/${pname}.svg \
|
|
|
|
&& ln -s $out/$pname/bin/${loName}.svg $out/share/icons/hicolor/scalable/apps/${pname}.svg
|
2022-03-30 09:31:56 +00:00
|
|
|
mv bin/fsnotifier* $out/libexec/${pname}/.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
jdk=${jdk.home}
|
|
|
|
item=${desktopItem}
|
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
wrapProgram "$out/$pname/bin/${loName}.sh" \
|
2023-07-15 17:15:38 +00:00
|
|
|
--prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git python3 ]}" \
|
2021-02-17 17:02:09 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([
|
2020-04-24 23:36:52 +00:00
|
|
|
# Some internals want libstdc++.so.6
|
2021-08-22 07:53:02 +00:00
|
|
|
stdenv.cc.cc.lib libsecret e2fsprogs
|
2020-04-24 23:36:52 +00:00
|
|
|
libnotify
|
2021-02-17 17:02:09 +00:00
|
|
|
] ++ extraLdPath)}" \
|
2021-12-19 01:06:50 +00:00
|
|
|
${lib.concatStringsSep " " extraWrapperArgs} \
|
2022-02-10 20:34:41 +00:00
|
|
|
--set-default JDK_HOME "$jdk" \
|
|
|
|
--set-default ANDROID_JAVA_HOME "$jdk" \
|
|
|
|
--set-default JAVA_HOME "$jdk" \
|
2022-10-21 18:38:19 +00:00
|
|
|
--set-default JETBRAINSCLIENT_JDK "$jdk" \
|
2020-04-24 23:36:52 +00:00
|
|
|
--set ${hiName}_JDK "$jdk" \
|
2020-12-25 13:55:36 +00:00
|
|
|
--set ${hiName}_VM_OPTIONS ${vmoptsFile}
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-08-04 22:07:22 +00:00
|
|
|
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
|
|
|
|
chmod +x $out/$pname/bin/remote-dev-server-wrapped.sh
|
|
|
|
ln -s "$out/$pname/bin/remote-dev-server-wrapped.sh" $out/bin/$pname-remote-dev-server
|
2020-04-24 23:36:52 +00:00
|
|
|
ln -s "$item/share/applications" $out/share
|
2021-07-14 22:03:04 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
2021-01-17 00:15:33 +00:00
|
|
|
} // lib.optionalAttrs (!(meta.license.free or true)) {
|
2020-04-24 23:36:52 +00:00
|
|
|
preferLocalBuild = true;
|
2021-12-06 16:07:01 +00:00
|
|
|
})
|