Merge pull request #31140 from ttuegel/dropbox

dropbox: use buildFHSUserEnv

authored by Thomas Tuegel and committed by GitHub a513c079 69d0eac9

+30 -120
+29 -119
pkgs/applications/networking/dropbox/default.nix
··· 1 - { mkDerivation, stdenv, lib, fetchurl, makeDesktopItem 2 - , makeWrapper, patchelf 3 - , dbus_libs, fontconfig, freetype, gcc, glib 4 - , libdrm, libffi, libICE, libSM 5 - , libX11, libXcomposite, libXext, libXmu, libXrender, libxcb 6 - , libxml2, libxslt, ncurses, zlib 7 - , qtbase, qtdeclarative, qtwebkit, wmctrl 8 - }: 1 + { stdenv, lib, buildFHSUserEnv, writeScript, makeDesktopItem }: 9 2 10 - # this package contains the daemon version of dropbox 11 - # it's unfortunately closed source 12 - # 13 - # note: the resulting program has to be invoced as 14 - # 'dropbox' because the internal python engine takes 15 - # uses the name of the program as starting point. 3 + let platforms = [ "i686-linux" "x86_64-linux" ]; in 16 4 17 - # Dropbox ships with its own copies of some libraries. 18 - # Unfortunately, upstream makes changes to the source of 19 - # some libraries, rendering them incompatible with the 20 - # open-source versions. Wherever possible, we must try 21 - # to make the bundled libraries work, rather than replacing 22 - # them with our own. 5 + assert lib.elem stdenv.system platforms; 23 6 7 + # Dropbox client to bootstrap installation. 8 + # The client is self-updating, so the actual version may be newer. 24 9 let 25 - ## Prefetch commands to run after update, from this directory: 26 - ## e.g. with Emacs: C-u M-x shell-command 27 - # nix-prefetch-url ../../../../ -A dropbox.src 28 - # nix-prefetch-url ../../../../ -A pkgsi686Linux.dropbox.src 29 - 30 - # NOTE: When updating, please also update in current stable, 31 - # as older versions stop working 32 - version = "37.4.29"; 33 - sha256 = { 34 - "x86_64-linux" = "0ymy8gb57bjq2mq35n52q2viww6am7wy0vskyvypliicggga8iaj"; 35 - "i686-linux" = "0a7zir6x7z3ad71fj1iljc2l6x09f4wi40jfaiinf8ykx85cldw6"; 36 - }."${stdenv.system}" or (throw "system ${stdenv.system} not supported"); 10 + version = "38.4.27"; 37 11 38 12 arch = { 39 13 "x86_64-linux" = "x86_64"; 40 14 "i686-linux" = "x86"; 41 - }."${stdenv.system}" or (throw "system ${stdenv.system} not supported"); 15 + }.${stdenv.system}; 42 16 43 - # relative location where the dropbox libraries are stored 44 - appdir = "opt/dropbox"; 17 + installer = "https://clientupdates.dropboxstatic.com/dbx-releng/client/dropbox-lnx.${arch}-${version}.tar.gz"; 18 + in 45 19 46 - libs = [ 47 - dbus_libs fontconfig freetype gcc.cc glib libdrm libffi libICE libSM 48 - libX11 libXcomposite libXext libXmu libXrender libxcb libxml2 libxslt 49 - ncurses zlib 50 - 51 - qtbase qtdeclarative qtwebkit 52 - ]; 53 - ldpath = stdenv.lib.makeLibraryPath libs; 54 - 20 + let 55 21 desktopItem = makeDesktopItem { 56 22 name = "dropbox"; 57 23 exec = "dropbox"; ··· 61 27 categories = "Network;FileTransfer;"; 62 28 startupNotify = "false"; 63 29 }; 64 - 65 - in mkDerivation { 66 - name = "dropbox-${version}"; 67 - src = fetchurl { 68 - name = "dropbox-${version}.tar.gz"; 69 - url = "https://clientupdates.dropboxstatic.com/dbx-releng/client/dropbox-lnx.${arch}-${version}.tar.gz"; 70 - inherit sha256; 71 - }; 72 - 73 - sourceRoot = ".dropbox-dist"; 74 - 75 - nativeBuildInputs = [ makeWrapper patchelf ]; 76 - buildInputs = libs; 77 - dontStrip = true; # already done 78 - 79 - installPhase = '' 80 - runHook preInstall 81 - 82 - mkdir -p "$out/${appdir}" 83 - cp -r --no-preserve=mode "dropbox-lnx.${arch}-${version}"/* "$out/${appdir}/" 30 + in 84 31 85 - # Vendored libraries interact poorly with our graphics drivers 86 - rm "$out/${appdir}/libdrm.so.2" 87 - rm "$out/${appdir}/libffi.so.6" 88 - rm "$out/${appdir}/libGL.so.1" 89 - rm "$out/${appdir}/libX11-xcb.so.1" 32 + buildFHSUserEnv { 33 + name = "dropbox"; 90 34 91 - # Cannot use vendored Qt libraries due to problem with xkbcommon 92 - rm "$out/${appdir}/"libQt5*.so.5 93 - rm "$out/${appdir}/qt.conf" 94 - rm -fr "$out/${appdir}/plugins" 35 + targetPkgs = pkgs: with pkgs; with xlibs; [ 36 + libICE libSM libX11 libXcomposite libXdamage libXext libXfixes libXrender 37 + libXxf86vm libxcb 38 + curl dbus fontconfig freetype gcc glib gnutar libxml2 libxslt zlib 39 + ]; 95 40 41 + extraInstallCommands = '' 96 42 mkdir -p "$out/share/applications" 97 43 cp "${desktopItem}/share/applications/"* $out/share/applications 98 - 99 - mkdir -p "$out/share/icons" 100 - ln -s "$out/${appdir}/images/hicolor" "$out/share/icons/hicolor" 101 - 102 - mkdir -p "$out/bin" 103 - RPATH="${ldpath}:$out/${appdir}" 104 - chmod 755 $out/${appdir}/dropbox 105 - makeWrapper "$out/${appdir}/dropbox" "$out/bin/dropbox" \ 106 - --prefix LD_LIBRARY_PATH : "$RPATH" 107 - 108 - 109 - rm $out/${appdir}/wmctrl 110 - ln -s ${wmctrl}/bin/wmctrl $out/${appdir}/wmctrl 111 - 112 - runHook postInstall 113 44 ''; 114 45 115 - preFixup = '' 116 - INTERP=$(cat $NIX_CC/nix-support/dynamic-linker) 117 - RPATH="${ldpath}:$out/${appdir}" 118 - getType='s/ *Type: *\([A-Z]*\) (.*/\1/' 119 - find "$out/${appdir}" -type f -print | while read obj; do 120 - dynamic=$(readelf -S "$obj" 2>/dev/null | grep "DYNAMIC" || true) 121 - if [[ -n "$dynamic" ]]; then 122 - 123 - if readelf -l "$obj" 2>/dev/null | grep "INTERP" >/dev/null; then 124 - echo "patching interpreter path in $type $obj" 125 - patchelf --set-interpreter "$INTERP" "$obj" 126 - fi 127 - 128 - type=$(readelf -h "$obj" 2>/dev/null | grep 'Type:' | sed -e "$getType") 129 - if [ "$type" == "EXEC" ] || [ "$type" == "DYN" ]; then 130 - 131 - echo "patching RPATH in $type $obj" 132 - oldRPATH=$(patchelf --print-rpath "$obj") 133 - patchelf --set-rpath "''${oldRPATH:+$oldRPATH:}$RPATH" "$obj" 134 - 135 - else 136 - 137 - echo "unknown ELF type \"$type\"; not patching $obj" 138 - 139 - fi 140 - fi 141 - done 142 - 143 - paxmark m $out/${appdir}/dropbox 46 + runScript = writeScript "install-and-start-dropbox" '' 47 + if ! [ -d "$HOME/.dropbox-dist" ]; then 48 + # Dropbox is not installed. 49 + # Download and unpack the client. If a newer version is available, 50 + # the client will update itself when run. 51 + curl '${installer}' | tar -C "$HOME" -x -z 52 + fi 53 + exec "$HOME/.dropbox-dist/dropboxd" 144 54 ''; 145 55 146 56 meta = with lib; { 147 57 description = "Online stored folders (daemon version)"; 148 - homepage = http://www.dropbox.com; 149 - maintainers = with maintainers; [ ttuegel ]; 58 + homepage = http://www.dropbox.com/; 150 59 license = licenses.unfree; 60 + maintainers = with maintainers; [ ttuegel ]; 151 61 platforms = [ "i686-linux" "x86_64-linux" ]; 152 62 }; 153 63 }
+1 -1
pkgs/top-level/all-packages.nix
··· 16520 16520 bittorrentSync14 = callPackage ../applications/networking/bittorrentsync/1.4.x.nix { }; 16521 16521 bittorrentSync20 = callPackage ../applications/networking/bittorrentsync/2.0.x.nix { }; 16522 16522 16523 - dropbox = libsForQt5.callPackage ../applications/networking/dropbox { }; 16523 + dropbox = callPackage ../applications/networking/dropbox { }; 16524 16524 16525 16525 dropbox-cli = callPackage ../applications/networking/dropbox-cli { }; 16526 16526