Commit f7bfb80a authored by Stanisław Pitucha's avatar Stanisław Pitucha
Browse files

reaper: add darwin platform

parent 5105831e
Loading
Loading
Loading
Loading
+25 −10
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@
, fetchurl
, autoPatchelfHook
, makeWrapper
, undmg

, alsa-lib
, curl
@@ -14,14 +15,16 @@
, xdotool
, which

, jackSupport ? true
, jackSupport ? stdenv.isLinux
, jackLibrary
, pulseaudioSupport ? config.pulseaudio or true
, pulseaudioSupport ? config.pulseaudio or stdenv.isLinux
, libpulseaudio
}:

let
  url_for_platform = version: arch: "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_${arch}.tar.xz";
  url_for_platform = version: arch: if stdenv.isDarwin
    then "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_universal.dmg"
    else "https://www.reaper.fm/files/${lib.versions.major version}.x/reaper${builtins.replaceStrings ["."] [""] version}_linux_${arch}.tar.xz";
in
stdenv.mkDerivation rec {
  pname = "reaper";
@@ -29,26 +32,32 @@ stdenv.mkDerivation rec {

  src = fetchurl {
    url = url_for_platform version stdenv.hostPlatform.qemuArch;
    hash = {
    hash = if stdenv.isDarwin then "sha256-jaT+3cIFVfBopgeeTkpNs9rFX50unlPJogdhkI9bsWU=" else {
      x86_64-linux = "sha256-P/PnbJPr4ErDz5ho1/dLERhqkKjdetHzKpCpfVZAYb0=";
      aarch64-linux = "sha256-PdnBVlHwoEEv2SPq/p5oyiOlduCEqL35gAY+QIJU1Ys=";
    }.${stdenv.hostPlatform.system};
  };

  nativeBuildInputs = [
    autoPatchelfHook
    makeWrapper
    xdg-utils # Required for desktop integration
  ] ++ lib.optionals stdenv.isLinux [
    which
    autoPatchelfHook
    xdg-utils # Required for desktop integration
  ] ++ lib.optionals stdenv.isDarwin [
    undmg
  ];

  sourceRoot = lib.optionalString stdenv.isDarwin "Reaper.app";

  buildInputs = [
    alsa-lib
    stdenv.cc.cc.lib # reaper and libSwell need libstdc++.so.6
  ] ++ lib.optionals stdenv.isLinux [
    gtk3
    alsa-lib
  ];

  runtimeDependencies = [
  runtimeDependencies = lib.optionals stdenv.isLinux [
    gtk3 # libSwell needs libgdk-3.so.0
  ]
  ++ lib.optional jackSupport jackLibrary
@@ -56,7 +65,13 @@ stdenv.mkDerivation rec {

  dontBuild = true;

  installPhase = ''
  installPhase = if stdenv.isDarwin then ''
    runHook preInstall
    mkdir -p "$out/Applications/Reaper.app"
    cp -r * "$out/Applications/Reaper.app/"
    makeWrapper "$out/Applications/Reaper.app/Contents/MacOS/REAPER" "$out/bin/reaper"
    runHook postInstall
  '' else ''
    runHook preInstall

    HOME="$out/share" XDG_DATA_HOME="$out/share" ./install-reaper.sh \
@@ -89,7 +104,7 @@ stdenv.mkDerivation rec {
    homepage = "https://www.reaper.fm/";
    sourceProvenance = with sourceTypes; [ binaryNativeCode ];
    license = licenses.unfree;
    platforms = [ "x86_64-linux" "aarch64-linux" ];
    platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
    maintainers = with maintainers; [ jfrankenau ilian orivej uniquepointer viraptor ];
  };
}
+13 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ set -euo pipefail

reaper_ver=$(curl -Ls https://www.reaper.fm/download.php | grep -o 'Version [0-9]\.[0-9]*' | head -n1 | cut -d' ' -f2)

function set_hash_for_arch() {
function set_hash_for_linux() {
  local arch=$1
  pkg_hash=$(nix-prefetch-url https://www.reaper.fm/files/${reaper_ver%.*}.x/reaper${reaper_ver/./}_linux_$arch.tar.xz)
  pkg_hash=$(nix hash to-sri "sha256:$pkg_hash")
@@ -14,5 +14,15 @@ function set_hash_for_arch() {
  update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-linux
}

set_hash_for_arch aarch64
set_hash_for_arch x86_64
function set_hash_for_darwin() {
  local arch=$1
  pkg_hash=$(nix-prefetch-url https://www.reaper.fm/files/${reaper_ver%.*}.x/reaper${reaper_ver/./}_universal.dmg)
  pkg_hash=$(nix hash to-sri "sha256:$pkg_hash")
  # reset the version so the second architecture update doesn't get ignored
  update-source-version reaper 0 "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" --system=$arch-darwin
  update-source-version reaper "${reaper_ver}" "$pkg_hash" --system=$arch-darwin
}

set_hash_for_linux aarch64
set_hash_for_linux x86_64
set_hash_for_darwin aarch64