2016-01-15 17:18:54 +00:00
|
|
|
{ stdenv, fetchurl, makeDesktopItem, makeWrapper, patchelf, p7zip
|
2016-06-21 10:07:56 +01:00
|
|
|
, coreutils, gnugrep, which, git, python, unzip }:
|
2016-01-15 17:18:54 +00:00
|
|
|
|
2016-06-21 10:07:56 +01:00
|
|
|
{ name, product, version, build, src, wmClass, jdk, meta } @ attrs:
|
2016-01-15 17:18:54 +00:00
|
|
|
|
|
|
|
with stdenv.lib;
|
|
|
|
|
|
|
|
let loName = toLower product;
|
|
|
|
hiName = toUpper product;
|
|
|
|
execName = concatStringsSep "-" (init (splitString "-" name));
|
|
|
|
in
|
|
|
|
|
|
|
|
with stdenv; lib.makeOverridable mkDerivation rec {
|
|
|
|
inherit name build src meta;
|
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = execName;
|
|
|
|
exec = execName;
|
|
|
|
comment = lib.replaceChars ["\n"] [" "] meta.longDescription;
|
|
|
|
desktopName = product;
|
|
|
|
genericName = meta.description;
|
|
|
|
categories = "Application;Development;";
|
|
|
|
icon = execName;
|
2016-05-25 03:43:13 +01:00
|
|
|
extraEntries = ''
|
|
|
|
StartupWMClass=${wmClass}
|
|
|
|
'';
|
2016-01-15 17:18:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
buildInputs = [ makeWrapper patchelf p7zip unzip ];
|
|
|
|
|
|
|
|
patchPhase = ''
|
|
|
|
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)
|
2016-01-15 17:18:54 +00:00
|
|
|
if [ "${stdenv.system}" == "x86_64-linux" ]; then
|
|
|
|
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
|
|
|
|
ln -s $out/$name/bin/${loName}.png $out/share/pixmaps/${execName}.png
|
|
|
|
mv bin/fsnotifier* $out/libexec/${name}/.
|
|
|
|
|
|
|
|
jdk=${jdk.home}
|
|
|
|
item=${desktopItem}
|
|
|
|
|
|
|
|
makeWrapper "$out/$name/bin/${loName}.sh" "$out/bin/${execName}" \
|
2016-08-22 23:13:49 +01:00
|
|
|
--prefix PATH : "$out/libexec/${name}:${stdenv.lib.makeBinPath [ jdk coreutils gnugrep which git ]}" \
|
2016-01-15 17:18:54 +00:00
|
|
|
--set JDK_HOME "$jdk" \
|
|
|
|
--set ${hiName}_JDK "$jdk" \
|
|
|
|
--set ANDROID_JAVA_HOME "$jdk" \
|
|
|
|
--set JAVA_HOME "$jdk"
|
|
|
|
|
|
|
|
ln -s "$item/share/applications" $out/share
|
|
|
|
'';
|
|
|
|
|
|
|
|
}
|