NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.08k stars 14.13k forks source link

Package request: `megacmd` for darwin #297586

Open UlyssesZh opened 7 months ago

UlyssesZh commented 7 months ago

https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/misc/megacmd/default.nix

Here is my attempt to make it work for darwin, but it fails to build:

{ lib
, stdenv
, autoreconfHook
, c-ares
, cryptopp
, curl
, fetchFromGitHub
  # build fails with latest ffmpeg, see https://github.com/meganz/MEGAcmd/issues/523.
  # to be re-enabled when patch available
  # , ffmpeg
, gcc-unwrapped
, libmediainfo
, libraw
, libsodium
, libuv
, libzen
, pcre-cpp
, pkg-config
, readline
, sqlite
, darwin
}:

let
  version = "1.6.3";
  srcOptions = if stdenv.isLinux then {
    rev = "${version}_Linux";
    sha256 = "sha256-JnxfFbM+NyeUrEMok62zlsQIxjrUvLLg4tUTiKPDZFc=";
  } else {
    rev = "${version}_macOS";
    sha256 = "sha256-JnxfFbM+NyeUrEMok62zlsQIxjrUvLLg4tUTiKPDZFc=";
  };
in stdenv.mkDerivation rec {
  pname = "megacmd";
  inherit version;

  src = fetchFromGitHub {
    inherit (srcOptions) rev sha256;
    owner = "meganz";
    repo = "MEGAcmd";
    fetchSubmodules = true;
  };

  enableParallelBuilding = true;
  nativeBuildInputs = [ autoreconfHook pkg-config ];

  buildInputs = [
    c-ares
    cryptopp
    curl
    # ffmpeg
    gcc-unwrapped
    libmediainfo
    libraw
    libsodium
    libuv
    libzen
    pcre-cpp
    readline
    sqlite
  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
    CoreFoundation
    CoreServices
    SystemConfiguration
    Cocoa
    DiskArbitration
  ]);

  configureFlags = [
    "--disable-curl-checks"
    "--disable-examples"
    "--with-cares"
    "--with-cryptopp"
    "--with-curl"
    # "--with-ffmpeg"
    "--without-freeimage" # disabled as freeimage is insecure
    "--with-libmediainfo"
    "--with-libuv"
    "--with-libzen"
    "--with-pcre"
    "--with-readline"
    "--with-sodium"
    "--with-termcap"
  ];

  patchPhase = ''
    # set libtool flag --tag=CXX for both linux and darwin
    sed -i -r 'N;N;N;s/if LINUX\n(A.*?")\nendif/\1/' sdk/Makefile.am
  '';

  meta = with lib; {
    description = "MEGA Command Line Interactive and Scriptable Application";
    homepage = "https://mega.io/cmd";
    license = with licenses; [ bsd2 gpl3Only ];
    platforms = platforms.darwin ++ platforms.linux;
    maintainers = with maintainers; [ lunik1 ];
  };
}

It fails during compiling. It complains that the type MacFileSystemAccess is undeclared. It is declared in sdk/include/mega/osx/megafs.h and defined in sdk/src/fs.cpp, but those files are not added to the compiling commands.

@lunik1 I would appreciate it very much if you could add darwin support to that package. Thank you!


Add a :+1: reaction to issues you find important.

lunik1 commented 7 months ago

Unfortunately my only macos machine is my work laptop and file sharing services such as MEGA are forbidden, so I will not be able to work on this.

lunik1 commented 7 months ago

The MacOS instructions in the megacmd README are a little strange: they require you to download a bundle of dependencies and a patched config.h distributed on MEGA. Not sure how you are supposed to download that without megacmd already built...

UlyssesZh commented 7 months ago

I don't think we should follow those instructions.