about summary refs log tree commit diff
path: root/pkgs/applications/networking/insync/default.nix
blob: 282d45513ced8451f91ce5d997b93fcbf1c4fac8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
{ lib
, writeShellScript
, buildFHSEnv
, stdenvNoCC
, fetchurl
, autoPatchelfHook
, dpkg
, nss
, libvorbis
, libdrm
, libGL
, wayland
, xkeyboard_config
, libthai
}:

let
  pname = "insync";
  version = "3.8.6.50504";
  meta = with lib; {
    platforms = ["x86_64-linux"];
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    maintainers = with maintainers; [ hellwolf ];
    homepage = "https://www.insynchq.com";
    description = "Google Drive sync and backup with multiple account support";
    longDescription = ''
     Insync is a commercial application that syncs your Drive files to your
     computer.  It has more advanced features than Google's official client
     such as multiple account support, Google Doc conversion, symlink support,
     and built in sharing.

     There is a 15-day free trial, and it is a paid application after that.

     Known bug(s):

     1) Currently the system try icon does not render correctly.
     2) libqtvirtualkeyboardplugin does not have necessary Qt library shipped from vendor.
    '';
  };

  insync-pkg = stdenvNoCC.mkDerivation {
    inherit pname version meta;

    src = fetchurl {
      # Find a binary from https://www.insynchq.com/downloads/linux#ubuntu.
      url = "https://cdn.insynchq.com/builds/linux/${pname}_${version}-lunar_amd64.deb";
      sha256 = "sha256-BxTFtQ1rAsOuhKnH5vsl3zkM7WOd+vjA4LKZGxl4jk0=";
    };

    buildInputs = [
      nss
      libvorbis
      libdrm
      libGL
      wayland
      libthai
    ];

    nativeBuildInputs = [ autoPatchelfHook dpkg ];

    unpackPhase = ''
      dpkg-deb --fsys-tarfile $src | tar -x --no-same-permissions --no-same-owner
    '';

    installPhase = ''
      runHook preInstall

      mkdir -p $out/bin $out/lib $out/share
      cp -R usr/* $out/

      # use system glibc
      rm $out/lib/insync/{libgcc_s.so.1,libstdc++.so.6}

      # remove badly packaged plugins
      rm $out/lib/insync/PySide2/plugins/platforminputcontexts/libqtvirtualkeyboardplugin.so

      runHook postInstall
    '';

    # NB! This did the trick, otherwise it segfaults! However I don't understand why!
    dontStrip = true;
  };

  insync-fhsenv = buildFHSEnv {
    name = "${pname}-${version}";
    inherit meta;

    # for including insync's xdg data dirs
    extraOutputsToInstall = [ "share" ];

    targetPkgs = pkgs: with pkgs; [
      insync-pkg
      libudev0-shim
    ];

    runScript = writeShellScript "insync-wrapper.sh" ''
    # QT_STYLE_OVERRIDE was used to suppress a QT warning, it should have no actual effect for this binary.
    export QT_STYLE_OVERRIDE=Fusion
    # xkb configuration needed: https://github.com/NixOS/nixpkgs/issues/236365
    export XKB_CONFIG_ROOT=${xkeyboard_config}/share/X11/xkb/
    exec "${insync-pkg.outPath}/lib/insync/insync" "$@"
    '';

    # "insync start" command starts a daemon.
    dieWithParent = false;
  };

in stdenvNoCC.mkDerivation {
  inherit pname version meta;

  dontUnpack = true;
  installPhase = ''
    mkdir -p $out/bin
    ln -s ${insync-fhsenv}/bin/${insync-fhsenv.name} $out/bin/insync
    ln -s ${insync-pkg}/share $out/share
  '';
}