lol
1{ stdenv, lib, buildFHSUserEnv, writeScript, makeDesktopItem }:
2
3let platforms = [ "i686-linux" "x86_64-linux" ]; in
4
5assert lib.elem stdenv.hostPlatform.system platforms;
6
7# Dropbox client to bootstrap installation.
8# The client is self-updating, so the actual version may be newer.
9let
10 version = "55.4.171";
11
12 arch = {
13 "x86_64-linux" = "x86_64";
14 "i686-linux" = "x86";
15 }.${stdenv.hostPlatform.system};
16
17 installer = "https://clientupdates.dropboxstatic.com/dbx-releng/client/dropbox-lnx.${arch}-${version}.tar.gz";
18in
19
20let
21 desktopItem = makeDesktopItem {
22 name = "dropbox";
23 exec = "dropbox";
24 comment = "Sync your files across computers and to the web";
25 desktopName = "Dropbox";
26 genericName = "File Synchronizer";
27 categories = "Network;FileTransfer;";
28 startupNotify = "false";
29 };
30in
31
32buildFHSUserEnv {
33 name = "dropbox";
34
35 targetPkgs = pkgs: with pkgs; with xorg; [
36 libICE libSM libX11 libXcomposite libXdamage libXext libXfixes libXrender
37 libXxf86vm libxcb xkeyboardconfig
38 curl dbus firefox-bin fontconfig freetype gcc glib gnutar libxml2 libxslt
39 procps zlib
40 ];
41
42 extraInstallCommands = ''
43 mkdir -p "$out/share/applications"
44 cp "${desktopItem}/share/applications/"* $out/share/applications
45 '';
46
47 runScript = writeScript "install-and-start-dropbox" ''
48 export BROWSER=firefox
49
50 set -e
51
52 do_install=
53 if ! [ -d "$HOME/.dropbox-dist" ]; then
54 do_install=1
55 else
56 installed_version=$(cat "$HOME/.dropbox-dist/VERSION")
57 latest_version=$(printf "${version}\n$installed_version\n" | sort -rV | head -n 1)
58 if [ "x$installed_version" != "x$latest_version" ]; then
59 do_install=1
60 fi
61 fi
62
63 if [ -n "$do_install" ]; then
64 installer=$(mktemp)
65 # Dropbox is not installed.
66 # Download and unpack the client. If a newer version is available,
67 # the client will update itself when run.
68 curl '${installer}' >"$installer"
69 pkill dropbox || true
70 rm -fr "$HOME/.dropbox-dist"
71 tar -C "$HOME" -x -z -f "$installer"
72 rm "$installer"
73 fi
74
75 exec "$HOME/.dropbox-dist/dropboxd" "$@"
76 '';
77
78 meta = with lib; {
79 description = "Online stored folders (daemon version)";
80 homepage = http://www.dropbox.com/;
81 license = licenses.unfree;
82 maintainers = with maintainers; [ ttuegel ];
83 platforms = [ "i686-linux" "x86_64-linux" ];
84 };
85}