diff --git a/pkgs/applications/misc/megasync/default.nix b/pkgs/applications/misc/megasync/default.nix index ef35db703087..8ac1a9099e37 100644 --- a/pkgs/applications/misc/megasync/default.nix +++ b/pkgs/applications/misc/megasync/default.nix @@ -1,51 +1,69 @@ -{ lib -, stdenv -, autoconf -, automake -, c-ares -, cryptopp -, curl -, doxygen -, fetchFromGitHub -, ffmpeg -, libmediainfo -, libraw -, libsodium -, libtool -, libuv -, libzen -, lsb-release -, mkDerivation -, pkg-config -, qtbase -, qttools -, qtx11extras -, sqlite -, swig -, unzip -, wget +{ + lib, + stdenv, + c-ares, + cmake, + cryptopp, + curl, + fetchFromGitHub, + fetchpatch, + ffmpeg, + hicolor-icon-theme, + icu, + libmediainfo, + libsodium, + libtool, + libuv, + libxcb, + libzen, + mkDerivation, + openssl, + pkg-config, + qtbase, + qtdeclarative, + qtgraphicaleffects, + qttools, + qtquickcontrols, + qtquickcontrols2, + qtsvg, + qtx11extras, + readline, + sqlite, + unzip, + wget, + xorg, + zlib, + qt5, }: mkDerivation rec { pname = "megasync"; - version = "4.9.1.0"; + version = "5.6.1.0"; - src = fetchFromGitHub { + src = fetchFromGitHub rec { owner = "meganz"; repo = "MEGAsync"; rev = "v${version}_Linux"; - hash = "sha256-Y1nfY5iP64iSCYwzqxbjZAQNHyj4yVbSudSInm+yJzY="; - fetchSubmodules = true; + hash = "sha256-EjXmx+beYH3J60RidkEbZHFS5ZAOpJKmNC+WCIM84RA="; + fetchSubmodules = false; # DesignTokensImporter cannot be fetched, see #1010 in github:meganz/megasync + leaveDotGit = true; + postFetch = '' + cd $out + + git remote add origin $url + git fetch origin + git clean -fdx + git checkout ${rev} + git submodule update --init src/MEGASync/mega + + rm -rf .git + ''; # Why so complicated, I just want a single submodule }; nativeBuildInputs = [ - autoconf - automake - doxygen + cmake libtool - lsb-release pkg-config qttools - swig unzip ]; buildInputs = [ @@ -53,23 +71,40 @@ mkDerivation rec { cryptopp curl ffmpeg + hicolor-icon-theme + icu libmediainfo - libraw libsodium libuv + libxcb libzen + openssl qtbase + qtdeclarative + qtgraphicaleffects + qtquickcontrols + qtquickcontrols2 + qtsvg qtx11extras + readline sqlite wget + zlib ]; patches = [ - # Distro and version targets attempt to use lsb_release which is broken - # (see issue: https://github.com/NixOS/nixpkgs/issues/22729) - ./noinstall-distro-version.patch - # megasync target is not part of the install rule thanks to a commented block - ./install-megasync.patch + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/020-megasync-sdk-fix-cmake-dependencies-detection.patch?h=megasync&id=4b1eca5bc0d75709dee3a1260264d1b6386d3398"; + hash = "sha256-y3WhLkawFzQRzzRBpioiyAT3F1NDQvYBOm2888g5V5c="; + extraPrefix = "src/MEGASync/mega/"; + stripLen = true; + }) + (fetchpatch { + url = "https://aur.archlinux.org/cgit/aur.git/plain/030-megasync-app-fix-cmake-dependencies-detection.patch?h=megasync&id=4b1eca5bc0d75709dee3a1260264d1b6386d3398"; + hash = "sha256-11XWctv1veUEguc9Xvz2hMYw26CaCwu6M4hyA+5r81U="; + }) + ./megasync-fix-cmake-install-bindir.patch + ./dont-fetch-clang-format.patch ]; postPatch = '' @@ -81,46 +116,24 @@ mkDerivation rec { dontUseQmakeConfigure = true; enableParallelBuilding = true; - preConfigure = '' - cd src/MEGASync/mega - ./autogen.sh - ''; - - configureFlags = [ - "--disable-examples" - "--disable-java" - "--disable-php" - "--enable-chat" - "--with-cares" - "--with-cryptopp" - "--with-curl" - "--with-ffmpeg" - "--without-freeimage" - "--without-readline" - "--without-termcap" - "--with-sodium" - "--with-sqlite" - "--with-zlib" + cmakeFlags = [ + (lib.cmakeBool "USE_PDFIUM" false) # PDFIUM is not in nixpkgs + (lib.cmakeBool "USE_FREEIMAGE" false) # freeimage is insecure + (lib.cmakeBool "ENABLE_DESIGN_TOKENS_IMPORTER" false) # cannot be fetched ]; - postConfigure = '' - cd ../.. - ''; - - preBuild = '' - qmake CONFIG+="nofreeimage release" MEGA.pro - pushd MEGASync - lrelease MEGASync.pro - DESKTOP_DESTDIR="$out" qmake PREFIX="$out" -o Makefile MEGASync.pro CONFIG+="nofreeimage release" - popd + preFixup = '' + qtWrapperArgs+=(--prefix PATH : ${lib.makeBinPath [ xorg.xrdb ]}) ''; meta = with lib; { - description = - "Easy automated syncing between your computers and your MEGA Cloud Drive"; + description = "Easy automated syncing between your computers and your MEGA Cloud Drive"; homepage = "https://mega.nz/"; license = licenses.unfree; - platforms = [ "i686-linux" "x86_64-linux" ]; + platforms = [ + "i686-linux" + "x86_64-linux" + ]; maintainers = [ ]; }; } diff --git a/pkgs/applications/misc/megasync/dont-fetch-clang-format.patch b/pkgs/applications/misc/megasync/dont-fetch-clang-format.patch new file mode 100644 index 000000000000..ae76fbdcf5e2 --- /dev/null +++ b/pkgs/applications/misc/megasync/dont-fetch-clang-format.patch @@ -0,0 +1,10 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index b04f57067..0f6e7b163 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -63,5 +63,3 @@ include(desktopapp_configuration) + # Load the MEGA targets + add_subdirectory(src) + +-include(get_clang_format) +-get_clang_format() diff --git a/pkgs/applications/misc/megasync/install-megasync.patch b/pkgs/applications/misc/megasync/install-megasync.patch deleted file mode 100644 index 7d8748528e7f..000000000000 --- a/pkgs/applications/misc/megasync/install-megasync.patch +++ /dev/null @@ -1,21 +0,0 @@ -Index: source/src/MEGASync/MEGASync.pro -=================================================================== ---- source.orig/src/MEGASync/MEGASync.pro -+++ source/src/MEGASync/MEGASync.pro -@@ -28,11 +28,11 @@ unix:!macx { - TARGET = megasync - - # Uncomment the following if "make install" doesn't copy megasync in /usr/bin directory --# isEmpty(PREFIX) { --# PREFIX = /usr --# } --# target.path = $$PREFIX/bin --# INSTALLS += target -+ isEmpty(PREFIX) { -+ PREFIX = /usr -+ } -+ target.path = $$PREFIX/bin -+ INSTALLS += target - } - else { - TARGET = MEGAsync diff --git a/pkgs/applications/misc/megasync/megasync-fix-cmake-install-bindir.patch b/pkgs/applications/misc/megasync/megasync-fix-cmake-install-bindir.patch new file mode 100644 index 000000000000..8e15acf60e8f --- /dev/null +++ b/pkgs/applications/misc/megasync/megasync-fix-cmake-install-bindir.patch @@ -0,0 +1,12 @@ +diff --git a/contrib/cmake/modules/desktopapp_configuration.cmake b/contrib/cmake/modules/desktopapp_configuration.cmake +index 8e9f35cb2..b62f5a9b5 100644 +--- a/contrib/cmake/modules/desktopapp_configuration.cmake ++++ b/contrib/cmake/modules/desktopapp_configuration.cmake +@@ -30,7 +30,6 @@ if(UNIX AND NOT APPLE) + # Used for building packages: in which install dir is a path construction folder that will not be there in packages + + set(CMAKE_INSTALL_LIBDIR "opt/megasync/lib") # override default "lib" from GNUInstallDirs +- set(CMAKE_INSTALL_BINDIR "usr/bin") # override default "bin" from GNUInstallDirs + + # Override CMAKE_INSTALL_PREFIX + if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) # In consecutive runs it will always be undef/false diff --git a/pkgs/applications/misc/megasync/noinstall-distro-version.patch b/pkgs/applications/misc/megasync/noinstall-distro-version.patch deleted file mode 100644 index bbf100737bc4..000000000000 --- a/pkgs/applications/misc/megasync/noinstall-distro-version.patch +++ /dev/null @@ -1,13 +0,0 @@ -Index: source/src/MEGASync/platform/platform.pri -=================================================================== ---- source.orig/src/MEGASync/platform/platform.pri -+++ source/src/MEGASync/platform/platform.pri -@@ -37,7 +37,7 @@ unix:!macx { - system(command -v lsb_release): version.commands = lsb_release -rs > $$version.target - version.files = $$version.target - -- INSTALLS += distro version -+ # INSTALLS += distro version - - QT += dbus - SOURCES += $$PWD/linux/LinuxPlatform.cpp \