{ fetchurl, stdenv, dpkg, makeWrapper, which ,gcc, xorg, qt4, zlib , ...}: assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux"; let arch32 = "i686-linux"; arch64 = "x86_64-linux"; arch = if stdenv.system == arch32 then "i386" else "amd64"; shortVersion = "1.16.2-stable"; version = "${shortVersion}_${arch}"; url = "http://desktop-download.mendeley.com/download/apt/pool/main/m/mendeleydesktop/mendeleydesktop_${version}.deb"; sha256 = if stdenv.system == arch32 then "08f61972d5a5e491fcd3d4cf5dfe59ad7e07b3883b7ad50d440868c3057af6fb" else "9bd139b236143f78b23ff4271c01a20c059622abe9dd125e771e0b5db16b7b7b"; deps = [ gcc.cc qt4 xorg.libX11 zlib ]; in stdenv.mkDerivation { name = "mendeley-${version}"; src = fetchurl { url = url; sha256 = sha256; }; buildInputs = [ dpkg makeWrapper which ]; unpackPhase = "true"; installPhase = '' dpkg-deb -x $src $out mv $out/opt/mendeleydesktop/{bin,lib,plugins,share} $out interpreter=$(patchelf --print-interpreter $(readlink -f $(which patchelf))) patchelf --set-interpreter $interpreter $out/bin/mendeleydesktop librarypath="${stdenv.lib.makeLibraryPath deps}:$out/lib:$out/lib/qt" wrapProgram $out/bin/mendeleydesktop --prefix LD_LIBRARY_PATH : "$librarypath" ''; dontStrip = true; dontPatchElf = true; meta = { homepage = http://www.mendeley.com; description = "A reference manager and academic social network"; license = stdenv.lib.licenses.unfree; platforms = stdenv.lib.platforms.linux; }; }