nixpkgs/pkgs/applications/editors/jetbrains/bin/linux.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

162 lines
4.3 KiB
Nix
Raw Normal View History

2023-03-28 15:23:01 +00:00
{
stdenv,
lib,
makeDesktopItem,
makeWrapper,
patchelf,
writeText,
coreutils,
gnugrep,
which,
git,
unzip,
libsecret,
libnotify,
2023-08-14 12:09:39 +00:00
udev,
2023-03-28 15:23:01 +00:00
e2fsprogs,
python3,
autoPatchelfHook,
2023-03-28 15:23:01 +00:00
vmopts ? null,
glibcLocales,
}:
2016-01-15 17:18:54 +00:00
2023-03-28 15:23:01 +00:00
{
pname,
product,
productShort ? product,
version,
src,
wmClass,
buildNumber,
jdk,
meta,
libdbm,
fsnotifier,
2023-03-28 15:23:01 +00:00
extraLdPath ? [ ],
extraWrapperArgs ? [ ],
extraBuildInputs ? [ ],
2023-03-28 15:23:01 +00:00
}@args:
2016-01-15 17:18:54 +00:00
2023-03-28 15:23:01 +00:00
let
loName = lib.toLower productShort;
hiName = lib.toUpper productShort;
vmoptsName = loName + lib.optionalString stdenv.hostPlatform.is64bit "64" + ".vmoptions";
2016-01-15 17:18:54 +00:00
in
2021-10-30 06:19:46 +00:00
with stdenv;
lib.makeOverridable mkDerivation (
rec {
2022-03-22 16:57:23 +00:00
inherit pname version src;
2023-03-28 15:23:01 +00:00
passthru.buildNumber = buildNumber;
2022-03-22 16:57:23 +00:00
meta = args.meta // {
mainProgram = pname;
};
2016-01-15 17:18:54 +00:00
desktopItem = makeDesktopItem {
2022-03-22 16:57:23 +00:00
name = pname;
exec = pname;
2023-03-28 15:23:01 +00:00
comment = lib.replaceStrings [ "\n" ] [ " " ] meta.longDescription;
2016-01-15 17:18:54 +00:00
desktopName = product;
genericName = meta.description;
categories = [ "Development" ];
2022-03-22 16:57:23 +00:00
icon = pname;
startupWMClass = wmClass;
2016-01-15 17:18:54 +00:00
};
vmoptsIDE = if hiName == "WEBSTORM" then "WEBIDE" else hiName;
vmoptsFile = lib.optionalString (vmopts != null) (writeText vmoptsName vmopts);
nativeBuildInputs = [
makeWrapper
patchelf
unzip
autoPatchelfHook
];
buildInputs = extraBuildInputs;
2022-02-01 02:40:45 +00:00
postPatch = ''
2023-03-28 15:23:01 +00:00
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
if [ -d "plugins/remote-dev-server" ]; then
patch -F3 -p1 < ${../patches/jetbrains-remote-dev.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
2016-01-15 17:18:54 +00:00
'';
2016-01-15 17:18:54 +00:00
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,$pname,share/pixmaps,share/icons/hicolor/scalable/apps}
2022-03-22 16:57:23 +00:00
cp -a . $out/$pname
2022-11-04 20:45:20 +00:00
[[ -f $out/$pname/bin/${loName}.png ]] && ln -s $out/$pname/bin/${loName}.png $out/share/pixmaps/${pname}.png
[[ -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
cp ${libdbm}/lib/libdbm.so $out/$pname/bin/libdbm.so
cp ${fsnotifier}/bin/fsnotifier $out/$pname/bin/fsnotifier
2016-01-15 17:18:54 +00:00
jdk=${jdk.home}
item=${desktopItem}
launcher="$out/$pname/bin/${loName}"
if [ -e "$launcher" ]; then
rm "$launcher".sh # We do not wrap the old script-style launcher anymore.
else
launcher+=.sh
fi
wrapProgram "$launcher" \
--prefix PATH : "${
lib.makeBinPath [
jdk
coreutils
gnugrep
which
git
]
}" \
--suffix PATH : "${lib.makeBinPath [ python3 ]}" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath extraLdPath}" \
${lib.concatStringsSep " " extraWrapperArgs} \
--set-default JDK_HOME "$jdk" \
--set-default ANDROID_JAVA_HOME "$jdk" \
--set-default JAVA_HOME "$jdk" \
--set-default JETBRAINS_CLIENT_JDK "$jdk" \
--set-default ${hiName}_JDK "$jdk" \
--set-default LOCALE_ARCHIVE "${glibcLocales}/lib/locale/locale-archive" \
--set-default ${vmoptsIDE}_VM_OPTIONS ${vmoptsFile}
ln -s "$launcher" $out/bin/$pname
rm -rf $out/$pname/plugins/remote-dev-server/selfcontained/
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
2016-01-15 17:18:54 +00:00
ln -s "$item/share/applications" $out/share
runHook postInstall
2016-01-15 17:18:54 +00:00
'';
2021-01-15 13:21:58 +00:00
}
// lib.optionalAttrs (!(meta.license.free or true)) {
preferLocalBuild = true;
2021-10-30 06:19:46 +00:00
}
)