nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 autoreconfHook,
5 c-ares,
6 cryptopp,
7 curl,
8 fetchFromGitHub,
9 ffmpeg,
10 freeimage,
11 gcc-unwrapped,
12 icu,
13 libmediainfo,
14 libraw,
15 libsodium,
16 libuv,
17 libzen,
18 pcre-cpp,
19 pkg-config,
20 readline,
21 sqlite,
22 withFreeImage ? false, # default to false because freeimage is insecure
23}:
24
25let
26 pname = "megacmd";
27 version = "1.7.0";
28 srcOptions =
29 if stdenv.hostPlatform.isLinux then
30 {
31 tag = "${version}_Linux";
32 hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
33 }
34 else
35 {
36 tag = "${version}_macOS";
37 hash = "sha256-UlSqwM8GQKeG8/K0t5DbM034NQOeBg+ujNi/MMsVCuM=";
38 };
39in
40stdenv.mkDerivation {
41 inherit pname version;
42
43 src = fetchFromGitHub (
44 srcOptions
45 // {
46 owner = "meganz";
47 repo = "MEGAcmd";
48 fetchSubmodules = true;
49 }
50 );
51
52 enableParallelBuilding = true;
53 nativeBuildInputs = [
54 autoreconfHook
55 pkg-config
56 ];
57
58 buildInputs =
59 lib.optionals stdenv.hostPlatform.isLinux [ gcc-unwrapped ] # fix: ld: cannot find lib64/libstdc++fs.a
60 ++ [
61 c-ares
62 cryptopp
63 curl
64 ffmpeg
65 icu
66 libmediainfo
67 libraw
68 libsodium
69 libuv
70 libzen
71 pcre-cpp
72 readline
73 sqlite
74 ]
75 ++ lib.optionals withFreeImage [ freeimage ];
76
77 configureFlags = [
78 "--disable-examples"
79 "--with-cares"
80 "--with-cryptopp"
81 "--with-curl"
82 "--with-ffmpeg"
83 "--with-icu"
84 "--with-libmediainfo"
85 "--with-libuv"
86 "--with-libzen"
87 "--with-pcre"
88 "--with-readline"
89 "--with-sodium"
90 "--with-termcap"
91 ]
92 ++ (if withFreeImage then [ "--with-freeimage" ] else [ "--without-freeimage" ]);
93
94 # On darwin, some macros defined in AssertMacros.h (from apple-sdk) are conflicting.
95 postConfigure = ''
96 echo '#define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0' >> sdk/include/mega/config.h
97 '';
98
99 patches = [
100 ./fix-ffmpeg.patch # https://github.com/meganz/sdk/issues/2635#issuecomment-1495405085
101 ./fix-darwin.patch # fix: libtool tag not found; MacFileSystemAccess not declared; server cannot init
102 ];
103
104 meta = {
105 description = "MEGA Command Line Interactive and Scriptable Application";
106 homepage = "https://mega.io/cmd";
107 license = with lib.licenses; [
108 bsd2
109 gpl3Only
110 ];
111 platforms = lib.platforms.linux ++ lib.platforms.darwin;
112 maintainers = with lib.maintainers; [
113 lunik1
114 ulysseszhan
115 ];
116 };
117}