@@ -0,0 +1,143 @@
1+{ lib
2+, stdenv
3+, autoconf
4+, automake
5+, bash
6+, bashInteractive
7+, c-ares
8+, cryptopp
9+, curl
10+, doxygen
11+, fetchFromGitHub
12+, hicolor-icon-theme
13+, libmediainfo
14+, libraw
15+, libsodium
16+, libtool
17+, libuv
18+, libzen
19+, lsb-release
20+, makeDesktopItem
21+, pkgconfig
22+, qt5
23+, sqlite
24+, swig
25+, unzip
26+, wget
27+, enableFFmpeg ? true, ffmpeg ? ffmpeg
28+}:
29+
30+assert enableFFmpeg -> ffmpeg != null;
31+
32+stdenv.mkDerivation rec {
33+ name = "megasync-${version}";
34+ version = "4.1.1.0";
35+
36+ src = fetchFromGitHub {
37+ owner = "meganz";
38+ repo = "MEGAsync";
39+ rev = "v${version}_Linux";
40+ sha256 = "0lc228q3s9xp78dxjn22g6anqlsy1hi7a6yfs4q3l6gyfc3qcxl2";
41+ fetchSubmodules = true;
42+ };
43+
44+ desktopItem = makeDesktopItem {
45+ name = "megasync";
46+ exec = "megasync";
47+ icon = "megasync";
48+ comment = meta.description;
49+ desktopName = "MEGASync";
50+ genericName = "File Synchronizer";
51+ categories = "Network;FileTransfer;";
52+ startupNotify = "false";
53+ };
54+
55+ nativeBuildInputs = [
56+ autoconf
57+ automake
58+ doxygen
59+ lsb-release
60+ pkgconfig
61+ qt5.qmake
62+ qt5.qttools
63+ swig
64+ ];
65+ buildInputs = [
66+ c-ares
67+ cryptopp
68+ curl
69+ #freeimage # unreferenced
70+ hicolor-icon-theme
71+ libmediainfo
72+ libraw
73+ libsodium
74+ libtool
75+ libuv
76+ libzen
77+ qt5.qtbase
78+ qt5.qtsvg
79+ sqlite
80+ unzip
81+ wget
82+ ] ++ stdenv.lib.optionals enableFFmpeg [ ffmpeg ];
83+
84+ patchPhase = ''
85+ for file in $(find src/ -type f \( -iname configure -o -iname \*.sh \) ); do
86+ substituteInPlace "$file" \
87+ --replace "/bin/bash" "${bashInteractive}/bin/bash"
88+ done
89+ '';
90+
91+ preConfigure = ''
92+ cd src/MEGASync/mega
93+ ./autogen.sh
94+ '';
95+
96+ configureScript = "./configure";
97+
98+ configureFlags = [
99+ "--disable-examples"
100+ "--disable-java"
101+ "--disable-php"
102+ "--enable-chat"
103+ "--with-cares"
104+ "--with-cryptopp"
105+ "--with-curl"
106+ "--without-freeimage" # unreferenced even when found
107+ "--without-readline"
108+ "--without-termcap"
109+ "--with-sodium"
110+ "--with-sqlite"
111+ "--with-zlib"
112+ ] ++ stdenv.lib.optionals enableFFmpeg ["--with-ffmpeg"];
113+
114+ # TODO: unless overriden, qmake is called instead ??
115+ configurePhase = ''
116+ runHook preConfigure
117+ ./configure ${toString configureFlags}
118+ runHook postConfigure
119+ '';
120+
121+ postConfigure = "cd ../..";
122+
123+ preBuild = ''
124+ qmake CONFIG+="release" MEGA.pro
125+ lrelease MEGASync/MEGASync.pro
126+ '';
127+
128+ # TODO: install bindings
129+ installPhase = ''
130+ mkdir -p $out/share/icons
131+ install -Dm 755 MEGASync/megasync $out/bin/megasync
132+ cp -r ${desktopItem}/share/applications $out/share
133+ cp MEGASync/gui/images/uptodate.svg $out/share/icons/megasync.svg
134+ '';
135+
136+ meta = with stdenv.lib; {
137+ description = "Easy automated syncing between your computers and your MEGA Cloud Drive";
138+ homepage = https://mega.nz/;
139+ license = licenses.free;
140+ platforms = [ "i686-linux" "x86_64-linux" ];
141+ maintainers = [ maintainers.michojel ];
142+ };
143+}