nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 writeShellScript,
4 buildFHSEnv,
5 stdenvNoCC,
6 fetchurl,
7 autoPatchelfHook,
8 dpkg,
9 nss,
10 alsa-lib,
11 lz4,
12 libgcrypt,
13 xkeyboard_config,
14 libthai,
15 libsForQt5,
16 xz,
17}:
18
19let
20 pname = "insync";
21 # Find a binary from https://www.insynchq.com/downloads/linux
22 version = "3.9.6.60027";
23 web-archive-id = "20250502161201"; # upload via https://web.archive.org/save/
24 debian-dist = "trixie_amd64";
25 insync-pkg = stdenvNoCC.mkDerivation {
26 pname = "${pname}-pkg";
27 inherit version;
28
29 src = fetchurl rec {
30 urls = [
31 "https://cdn.insynchq.com/builds/linux/${version}/insync_${version}-${debian-dist}.deb"
32 "https://web.archive.org/web/${web-archive-id}/${builtins.elemAt urls 0}"
33 ];
34 hash = "sha256-q1s4hFQTXjS9VmA6XETpsvEEES79b84y8zCZwpy3gKo=";
35 };
36
37 nativeBuildInputs = [
38 dpkg
39 autoPatchelfHook
40 libsForQt5.qt5.wrapQtAppsHook
41 ];
42
43 buildInputs = [
44 alsa-lib
45 nss
46 lz4
47 libgcrypt
48 libthai
49 xz
50 ]
51 ++ (with libsForQt5; [ qt5.qtvirtualkeyboard ]);
52
53 installPhase = ''
54 runHook preInstall
55
56 # Remove unused plugins. This is based on missing libraries from the upstream package.
57 rm -rf usr/lib/insync/PySide2/Qt/qml/
58
59 mkdir -p $out
60 cp -R usr/* $out/
61
62 runHook postInstall
63 '';
64
65 # NB! This did the trick, otherwise it segfaults! However I don't understand why!
66 dontStrip = true;
67 };
68
69in
70buildFHSEnv {
71 inherit pname version;
72
73 targetPkgs =
74 pkgs: with pkgs; [
75 libudev0-shim
76 insync-pkg
77 # Qt requires usr/share/icons/hicolor/index.theme file (provided by hicolor-icon-theme) to be
78 # present to successfully find the system tray icons.
79 hicolor-icon-theme
80 ];
81
82 extraInstallCommands = ''
83 cp -rsHf "${insync-pkg}"/share $out/
84 '';
85
86 runScript = writeShellScript "insync-wrapper.sh" ''
87 # xkb configuration needed: https://github.com/NixOS/nixpkgs/issues/236365
88 export XKB_CONFIG_ROOT=${xkeyboard_config}/share/X11/xkb/
89
90 # When using Ubuntu deb package, this might be needed for showing system tray icon.
91 # export XDG_CURRENT_DESKTOP=Unity
92
93 # For debugging:
94 # export QT_DEBUG_PLUGINS=1
95
96 exec /usr/lib/insync/insync "$@"
97 '';
98
99 # As intended by this bubble wrap, share as much namespaces as possible with user.
100 unshareUser = false;
101 unshareIpc = false;
102 unsharePid = false;
103 unshareNet = false;
104 unshareUts = false;
105 unshareCgroup = false;
106
107 dieWithParent = true;
108
109 meta = {
110 platforms = [ "x86_64-linux" ];
111 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
112 license = lib.licenses.unfree;
113 maintainers = with lib.maintainers; [ hellwolf ];
114 homepage = "https://www.insynchq.com";
115 description = "Google Drive sync and backup with multiple account support";
116 longDescription = ''
117 Insync is a commercial application that syncs your Drive files to your
118 computer. It has more advanced features than Google's official client
119 such as multiple account support, Google Doc conversion, symlink support,
120 and built in sharing.
121
122 There is a 15-day free trial, and it is a paid application after that.
123 '';
124 mainProgram = "insync";
125 };
126}