@@ -0,0 +1,125 @@
1+{ stdenv
2+, autoconf
3+, automake
4+, c-ares
5+, cryptopp
6+, curl
7+, doxygen
8+, fetchFromGitHub
9+, ffmpeg
10+, hicolor-icon-theme
11+, libmediainfo
12+, libraw
13+, libsodium
14+, libtool
15+, libuv
16+, libzen
17+, lsb-release
18+, pkgconfig
19+, qt5
20+, sqlite
21+, swig
22+, unzip
23+, wget
24+}:
25+
26+stdenv.mkDerivation rec {
27+ name = "megasync-${version}";
28+ version = "4.1.1.0";
29+
30+ src = fetchFromGitHub {
31+ owner = "meganz";
32+ repo = "MEGAsync";
33+ rev = "v${version}_Linux";
34+ sha256 = "0lc228q3s9xp78dxjn22g6anqlsy1hi7a6yfs4q3l6gyfc3qcxl2";
35+ fetchSubmodules = true;
36+ };
37+
38+ nativeBuildInputs = [
39+ autoconf
40+ automake
41+ doxygen
42+ lsb-release
43+ pkgconfig
44+ qt5.qmake
45+ qt5.qttools
46+ swig
47+ ];
48+ buildInputs = [
49+ c-ares
50+ cryptopp
51+ curl
52+ ffmpeg
53+ hicolor-icon-theme
54+ libmediainfo
55+ libraw
56+ libsodium
57+ libtool
58+ libuv
59+ libzen
60+ qt5.qtbase
61+ qt5.qtsvg
62+ sqlite
63+ unzip
64+ wget
65+ ];
66+
67+ patches = [
68+ # Distro and version targets attempt to use lsb_release which is broken
69+ # (see issue: https://github.com/NixOS/nixpkgs/issues/22729)
70+ ./noinstall-distro-version.patch
71+ # megasync target is not part of the install rule thanks to a commented block
72+ ./install-megasync.patch
73+ ];
74+
75+ postPatch = ''
76+ for file in $(find src/ -type f \( -iname configure -o -iname \*.sh \) ); do
77+ substituteInPlace "$file" --replace "/bin/bash" "${stdenv.shell}"
78+ done
79+ '';
80+
81+ dontUseQmakeConfigure = true;
82+ enableParallelBuilding = true;
83+
84+ preConfigure = ''
85+ cd src/MEGASync/mega
86+ ./autogen.sh
87+ '';
88+
89+ configureFlags = [
90+ "--disable-examples"
91+ "--disable-java"
92+ "--disable-php"
93+ "--enable-chat"
94+ "--with-cares"
95+ "--with-cryptopp"
96+ "--with-curl"
97+ "--with-ffmpeg"
98+ "--without-freeimage" # unreferenced even when found
99+ "--without-readline"
100+ "--without-termcap"
101+ "--with-sodium"
102+ "--with-sqlite"
103+ "--with-zlib"
104+ ];
105+
106+ postConfigure = ''
107+ cd ../..
108+ '';
109+
110+ preBuild = ''
111+ qmake CONFIG+="release" MEGA.pro
112+ pushd MEGASync
113+ lrelease MEGASync.pro
114+ DESKTOP_DESTDIR="$out" qmake PREFIX="$out" -o Makefile MEGASync.pro CONFIG+=release
115+ popd
116+ '';
117+
118+ meta = with stdenv.lib; {
119+ description = "Easy automated syncing between your computers and your MEGA Cloud Drive";
120+ homepage = https://mega.nz/;
121+ license = licenses.unfree;
122+ platforms = [ "i686-linux" "x86_64-linux" ];
123+ maintainers = [ maintainers.michojel ];
124+ };
125+}