2020-12-25 13:55:36 +00:00
|
|
|
{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf, writeText
|
2021-08-22 07:53:02 +00:00
|
|
|
, coreutils, gnugrep, which, git, unzip, libsecret, libnotify, e2fsprogs
|
2020-12-25 13:55:36 +00:00
|
|
|
, vmopts ? null
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
{ pname, product, productShort ? product, version, src, wmClass, jdk, meta, extraLdPath ? [], extraWrapperArgs ? [] }@args:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-01-17 00:15:33 +00:00
|
|
|
with lib;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
let loName = toLower productShort;
|
|
|
|
hiName = toUpper productShort;
|
2020-12-25 13:55:36 +00:00
|
|
|
vmoptsName = loName
|
2022-03-30 09:31:56 +00:00
|
|
|
+ lib.optionalString stdenv.hostPlatform.is64bit "64"
|
2020-12-25 13:55:36 +00:00
|
|
|
+ ".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;
|
|
|
|
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;
|
2020-04-24 23:36:52 +00:00
|
|
|
comment = lib.replaceChars ["\n"] [" "] meta.longDescription;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
vmoptsFile = optionalString (vmopts != null) (writeText vmoptsName vmopts);
|
|
|
|
|
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 = ''
|
2020-04-24 23:36:52 +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-06-16 17:23:12 +00:00
|
|
|
interpreter=$(echo ${stdenv.cc.libc}/lib/ld-linux*.so.2)
|
2021-08-06 21:57:35 +00:00
|
|
|
if [[ "${stdenv.hostPlatform.system}" == "x86_64-linux" && -e bin/fsnotifier64 ]]; then
|
2020-04-24 23:36:52 +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-14 22:03:04 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
mkdir -p $out/{bin,$pname,share/pixmaps,libexec/${pname}}
|
|
|
|
cp -a . $out/$pname
|
|
|
|
ln -s $out/$pname/bin/${loName}.png $out/share/pixmaps/${pname}.png
|
|
|
|
mv bin/fsnotifier* $out/libexec/${pname}/.
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
jdk=${jdk.home}
|
|
|
|
item=${desktopItem}
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
makeWrapper "$out/$pname/bin/${loName}.sh" "$out/bin/${pname}" \
|
|
|
|
--prefix PATH : "$out/libexec/${pname}:${lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
|
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" \
|
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
|
|
|
|
|
|
|
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
|
|
|
})
|