2020-12-19 22:14:02 +00:00
|
|
|
{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf, writeText
|
2021-08-21 13:32:23 +01:00
|
|
|
, coreutils, gnugrep, which, git, unzip, libsecret, libnotify, e2fsprogs
|
2020-12-19 22:14:02 +00:00
|
|
|
, vmopts ? null
|
2018-03-03 13:34:44 +00:00
|
|
|
}:
|
2016-01-15 17:18:54 +00:00
|
|
|
|
2021-10-09 22:20:30 +01:00
|
|
|
{ name, product, version, src, wmClass, jdk, meta, extraLdPath ? [], extraWrapperArgs ? [] }@args:
|
2016-01-15 17:18:54 +00:00
|
|
|
|
2021-01-15 13:21:58 +00:00
|
|
|
with lib;
|
2016-01-15 17:18:54 +00:00
|
|
|
|
|
|
|
let loName = toLower product;
|
|
|
|
hiName = toUpper product;
|
2021-06-03 13:25:20 +01:00
|
|
|
mainProgram = concatStringsSep "-" (init (splitString "-" name));
|
2020-12-19 22:14:02 +00:00
|
|
|
vmoptsName = loName
|
|
|
|
+ ( if (with stdenv.hostPlatform; (is32bit || isDarwin))
|
|
|
|
then ""
|
|
|
|
else "64" )
|
|
|
|
+ ".vmoptions";
|
2016-01-15 17:18:54 +00:00
|
|
|
in
|
|
|
|
|
2021-10-30 07:19:46 +01:00
|
|
|
with stdenv; lib.makeOverridable mkDerivation (rec {
|
2021-06-03 13:24:13 +01:00
|
|
|
inherit name src;
|
2021-06-03 13:25:20 +01:00
|
|
|
meta = args.meta // { inherit mainProgram; };
|
2021-06-03 13:24:13 +01:00
|
|
|
|
2016-01-15 17:18:54 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
2021-06-03 13:25:20 +01:00
|
|
|
name = mainProgram;
|
|
|
|
exec = mainProgram;
|
2016-01-15 17:18:54 +00:00
|
|
|
comment = lib.replaceChars ["\n"] [" "] meta.longDescription;
|
|
|
|
desktopName = product;
|
|
|
|
genericName = meta.description;
|
2022-02-22 14:56:15 +00:00
|
|
|
categories = [ "Development" ];
|
2021-06-03 13:25:20 +01:00
|
|
|
icon = mainProgram;
|
2022-02-22 14:56:15 +00:00
|
|
|
startupWMClass = wmClass;
|
2016-01-15 17:18:54 +00:00
|
|
|
};
|
|
|
|
|
2020-12-19 22:14:02 +00:00
|
|
|
vmoptsFile = optionalString (vmopts != null) (writeText vmoptsName vmopts);
|
|
|
|
|
2020-05-01 21:03:30 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper patchelf unzip ];
|
2016-01-15 17:18:54 +00:00
|
|
|
|
2021-07-03 08:20:31 +01:00
|
|
|
postPatch = lib.optionalString (!stdenv.isDarwin) ''
|
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
|
|
|
|
}
|
|
|
|
|
2016-01-24 07:29:16 +00:00
|
|
|
interpreter=$(echo ${stdenv.glibc.out}/lib/ld-linux*.so.2)
|
jetbrains: Check for 64 bit specific fsnotifier
In April, 2021, Jetbrains announced the end of support for 32-bit OS
IntelliJ-based IDEs[1]:
> The final major version that will be guaranteed to run on a 32-bit OS will be
> v2021.1 for all IntelliJ-based IDEs, including AppCode, Clion, DataGrip, GoLand,
> IntelliJ IDEA, PhpStorm, PyCharm, Rider, RubyMine, and WebStorm.
[1]: https://blog.jetbrains.com/idea/2021/04/end-of-support-for-32-bit-operating-systems-in-intellij-based-ides/
2021-07-30 12:52:35 +01:00
|
|
|
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 = ''
|
2021-07-03 08:20:31 +01:00
|
|
|
runHook preInstall
|
|
|
|
|
2016-01-15 17:18:54 +00:00
|
|
|
mkdir -p $out/{bin,$name,share/pixmaps,libexec/${name}}
|
|
|
|
cp -a . $out/$name
|
2021-06-03 13:25:20 +01:00
|
|
|
ln -s $out/$name/bin/${loName}.png $out/share/pixmaps/${mainProgram}.png
|
2016-01-15 17:18:54 +00:00
|
|
|
mv bin/fsnotifier* $out/libexec/${name}/.
|
|
|
|
|
|
|
|
jdk=${jdk.home}
|
|
|
|
item=${desktopItem}
|
|
|
|
|
2021-06-03 13:25:20 +01:00
|
|
|
makeWrapper "$out/$name/bin/${loName}.sh" "$out/bin/${mainProgram}" \
|
2021-01-15 13:21:58 +00:00
|
|
|
--prefix PATH : "$out/libexec/${name}:${lib.optionalString (stdenv.isDarwin) "${jdk}/jdk/Contents/Home/bin:"}${lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
|
2021-02-15 23:03:41 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([
|
2017-04-01 09:48:52 +01:00
|
|
|
# Some internals want libstdc++.so.6
|
2021-08-21 13:32:23 +01:00
|
|
|
stdenv.cc.cc.lib libsecret e2fsprogs
|
2018-10-02 10:38:30 +01:00
|
|
|
libnotify
|
2021-02-15 23:03:41 +00:00
|
|
|
] ++ extraLdPath)}" \
|
2021-10-09 22:20:30 +01:00
|
|
|
${lib.concatStringsSep " " extraWrapperArgs} \
|
2022-02-08 14:32:29 +00:00
|
|
|
--set-default JDK_HOME "$jdk" \
|
|
|
|
--set-default ANDROID_JAVA_HOME "$jdk" \
|
|
|
|
--set-default JAVA_HOME "$jdk" \
|
2016-01-15 17:18:54 +00:00
|
|
|
--set ${hiName}_JDK "$jdk" \
|
2020-12-19 22:14:02 +00:00
|
|
|
--set ${hiName}_VM_OPTIONS ${vmoptsFile}
|
2016-01-15 17:18:54 +00:00
|
|
|
|
|
|
|
ln -s "$item/share/applications" $out/share
|
2021-07-03 08:20:31 +01:00
|
|
|
|
|
|
|
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)) {
|
2019-09-12 21:22:31 +01:00
|
|
|
preferLocalBuild = true;
|
2021-10-30 07:19:46 +01:00
|
|
|
})
|