2020-12-19 23:14:02 +01:00
|
|
|
{ stdenv, lib, makeDesktopItem, makeWrapper, patchelf, writeText
|
2018-10-02 11:38:30 +02:00
|
|
|
, coreutils, gnugrep, which, git, unzip, libsecret, libnotify
|
2020-12-19 23:14:02 +01:00
|
|
|
, vmopts ? null
|
2018-03-03 14:34:44 +01:00
|
|
|
}:
|
2016-01-15 18:18:54 +01:00
|
|
|
|
2021-06-03 14:24:13 +02:00
|
|
|
{ name, product, version, src, wmClass, jdk, meta, extraLdPath ? [] }@args:
|
2016-01-15 18:18:54 +01:00
|
|
|
|
2021-01-15 14:21:58 +01:00
|
|
|
with lib;
|
2016-01-15 18:18:54 +01:00
|
|
|
|
|
|
|
let loName = toLower product;
|
|
|
|
hiName = toUpper product;
|
2021-06-03 14:25:20 +02:00
|
|
|
mainProgram = concatStringsSep "-" (init (splitString "-" name));
|
2020-12-19 23:14:02 +01:00
|
|
|
vmoptsName = loName
|
|
|
|
+ ( if (with stdenv.hostPlatform; (is32bit || isDarwin))
|
|
|
|
then ""
|
|
|
|
else "64" )
|
|
|
|
+ ".vmoptions";
|
2016-01-15 18:18:54 +01:00
|
|
|
in
|
|
|
|
|
|
|
|
with stdenv; lib.makeOverridable mkDerivation rec {
|
2021-06-03 14:24:13 +02:00
|
|
|
inherit name src;
|
2021-06-03 14:25:20 +02:00
|
|
|
meta = args.meta // { inherit mainProgram; };
|
2021-06-03 14:24:13 +02:00
|
|
|
|
2016-01-15 18:18:54 +01:00
|
|
|
desktopItem = makeDesktopItem {
|
2021-06-03 14:25:20 +02:00
|
|
|
name = mainProgram;
|
|
|
|
exec = mainProgram;
|
2016-01-15 18:18:54 +01:00
|
|
|
comment = lib.replaceChars ["\n"] [" "] meta.longDescription;
|
|
|
|
desktopName = product;
|
|
|
|
genericName = meta.description;
|
2020-04-20 07:16:14 +02:00
|
|
|
categories = "Development;";
|
2021-06-03 14:25:20 +02:00
|
|
|
icon = mainProgram;
|
2016-05-25 04:43:13 +02:00
|
|
|
extraEntries = ''
|
|
|
|
StartupWMClass=${wmClass}
|
|
|
|
'';
|
2016-01-15 18:18:54 +01:00
|
|
|
};
|
|
|
|
|
2020-12-19 23:14:02 +01:00
|
|
|
vmoptsFile = optionalString (vmopts != null) (writeText vmoptsName vmopts);
|
|
|
|
|
2020-05-01 22:03:30 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper patchelf unzip ];
|
2016-01-15 18:18:54 +01:00
|
|
|
|
2019-07-09 08:48:26 +02:00
|
|
|
patchPhase = lib.optionalString (!stdenv.isDarwin) ''
|
2016-01-15 18:18:54 +01: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 08:29:16 +01:00
|
|
|
interpreter=$(echo ${stdenv.glibc.out}/lib/ld-linux*.so.2)
|
2018-08-20 21:11:29 +02:00
|
|
|
if [ "${stdenv.hostPlatform.system}" == "x86_64-linux" ]; then
|
2016-01-15 18:18:54 +01: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 = ''
|
|
|
|
mkdir -p $out/{bin,$name,share/pixmaps,libexec/${name}}
|
|
|
|
cp -a . $out/$name
|
2021-06-03 14:25:20 +02:00
|
|
|
ln -s $out/$name/bin/${loName}.png $out/share/pixmaps/${mainProgram}.png
|
2016-01-15 18:18:54 +01:00
|
|
|
mv bin/fsnotifier* $out/libexec/${name}/.
|
|
|
|
|
|
|
|
jdk=${jdk.home}
|
|
|
|
item=${desktopItem}
|
|
|
|
|
2021-06-03 14:25:20 +02:00
|
|
|
makeWrapper "$out/$name/bin/${loName}.sh" "$out/bin/${mainProgram}" \
|
2021-01-15 14:21:58 +01:00
|
|
|
--prefix PATH : "$out/libexec/${name}:${lib.optionalString (stdenv.isDarwin) "${jdk}/jdk/Contents/Home/bin:"}${lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
|
2021-02-16 00:03:41 +01:00
|
|
|
--prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath ([
|
2017-04-01 10:48:52 +02:00
|
|
|
# Some internals want libstdc++.so.6
|
2018-03-03 14:34:44 +01:00
|
|
|
stdenv.cc.cc.lib libsecret
|
2018-10-02 11:38:30 +02:00
|
|
|
libnotify
|
2021-02-16 00:03:41 +01:00
|
|
|
] ++ extraLdPath)}" \
|
2016-01-15 18:18:54 +01:00
|
|
|
--set JDK_HOME "$jdk" \
|
|
|
|
--set ${hiName}_JDK "$jdk" \
|
|
|
|
--set ANDROID_JAVA_HOME "$jdk" \
|
2020-12-19 23:14:02 +01:00
|
|
|
--set JAVA_HOME "$jdk" \
|
|
|
|
--set ${hiName}_VM_OPTIONS ${vmoptsFile}
|
2016-01-15 18:18:54 +01:00
|
|
|
|
|
|
|
ln -s "$item/share/applications" $out/share
|
|
|
|
'';
|
|
|
|
|
2021-01-15 14:21:58 +01:00
|
|
|
} // lib.optionalAttrs (!(meta.license.free or true)) {
|
2019-09-12 22:22:31 +02:00
|
|
|
preferLocalBuild = true;
|
2016-01-15 18:18:54 +01:00
|
|
|
}
|