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

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

96 lines
3.1 KiB
Nix
Raw Normal View History

{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf, writeText
, coreutils, gnugrep, which, git, unzip, libsecret, libnotify, e2fsprogs
, vmopts ? null
}:
2016-01-15 17:18:54 +00:00
2022-03-22 16:57:23 +00:00
{ pname, product, productShort ? product, version, src, wmClass, jdk, meta, extraLdPath ? [], extraWrapperArgs ? [] }@args:
2016-01-15 17:18:54 +00:00
let loName = lib.toLower productShort;
hiName = lib.toUpper productShort;
vmoptsName = loName
2022-02-01 02:40:45 +00:00
+ 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;
meta = args.meta // { mainProgram = pname; };
2021-06-03 12:24:13 +00:00
2016-01-15 17:18:54 +00:00
desktopItem = makeDesktopItem {
2022-03-22 16:57:23 +00:00
name = pname;
exec = pname;
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
};
vmoptsFile = lib.optionalString (vmopts != null) (writeText vmoptsName vmopts);
nativeBuildInputs = [ makeWrapper patchelf unzip ];
2016-01-15 17:18:54 +00:00
2022-02-01 02:40:45 +00:00
postPatch = ''
2016-01-15 17:18:54 +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
}
2022-10-18 22:17:38 +00:00
rm -rf jbr
interpreter=$(echo ${stdenv.cc.libc}/lib/ld-linux*.so.2)
if [[ "${stdenv.hostPlatform.system}" == "x86_64-linux" && -e bin/fsnotifier64 ]]; then
2016-01-15 17:18:54 +00:00
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 = ''
runHook preInstall
2022-03-22 16:57:23 +00:00
mkdir -p $out/{bin,$pname,share/pixmaps,libexec/${pname}}
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
2022-03-22 16:57:23 +00:00
mv bin/fsnotifier* $out/libexec/${pname}/.
2016-01-15 17:18:54 +00:00
jdk=${jdk.home}
item=${desktopItem}
2022-03-22 16:57:23 +00:00
makeWrapper "$out/$pname/bin/${loName}.sh" "$out/bin/${pname}" \
--prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([
2017-04-01 08:48:52 +00:00
# Some internals want libstdc++.so.6
stdenv.cc.cc.lib libsecret e2fsprogs
libnotify
] ++ extraLdPath)}" \
${lib.concatStringsSep " " extraWrapperArgs} \
--set-default JDK_HOME "$jdk" \
--set-default ANDROID_JAVA_HOME "$jdk" \
--set-default JAVA_HOME "$jdk" \
--set-default JETBRAINSCLIENT_JDK "$jdk" \
2016-01-15 17:18:54 +00:00
--set ${hiName}_JDK "$jdk" \
--set ${hiName}_VM_OPTIONS ${vmoptsFile}
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
})