summary refs log tree commit diff
path: root/pkgs/tools/archivers
diff options
context:
space:
mode:
authorThiago Kenji Okada <thiagokokada@gmail.com>2021-10-06 21:43:19 -0300
committerThiago Kenji Okada <thiagokokada@gmail.com>2021-11-10 21:56:38 -0300
commit6add5e065646a8e21460d2b5e546175063dfdc58 (patch)
treebfdb924421a7ddc377e63ac342d0227f68493c6d /pkgs/tools/archivers
parent05abd836d291cadd93d18fdb03898e26f1df7a77 (diff)
downloadnixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar.gz
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar.bz2
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar.lz
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar.xz
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.tar.zst
nixpkgs-6add5e065646a8e21460d2b5e546175063dfdc58.zip
unar: make it build on Darwin
Co-authored-by: Dmitry Kalinkin <dmitry.kalinkin@gmail.com>
Diffstat (limited to 'pkgs/tools/archivers')
-rw-r--r--pkgs/tools/archivers/unar/default.nix70
1 files changed, 51 insertions, 19 deletions
diff --git a/pkgs/tools/archivers/unar/default.nix b/pkgs/tools/archivers/unar/default.nix
index f3f7b32e119..5ce51fb0134 100644
--- a/pkgs/tools/archivers/unar/default.nix
+++ b/pkgs/tools/archivers/unar/default.nix
@@ -1,4 +1,17 @@
-{ lib, stdenv, fetchFromGitHub, installShellFiles, gnustep, bzip2, zlib, icu, openssl, wavpack }:
+{ lib
+, stdenv
+, fetchFromGitHub
+, installShellFiles
+, gnustep
+, bzip2
+, zlib
+, icu
+, openssl
+, wavpack
+, xcbuildHook
+, Foundation
+, AppKit
+}:
 
 stdenv.mkDerivation rec {
   pname = "unar";
@@ -12,35 +25,54 @@ stdenv.mkDerivation rec {
     sha256 = "0p846q1l66k3rnd512sncp26zpv411b8ahi145sghfcsz9w8abc4";
   };
 
-  postPatch = ''
-    for f in Makefile.linux ../UniversalDetector/Makefile.linux ; do
-      substituteInPlace $f \
-        --replace "= gcc" "=${stdenv.cc.targetPrefix}cc" \
-        --replace "= g++" "=${stdenv.cc.targetPrefix}c++" \
-        --replace "-DGNU_RUNTIME=1" "" \
-        --replace "-fgnu-runtime" "-fobjc-nonfragile-abi"
-    done
+  postPatch =
+    if stdenv.isDarwin then ''
+      substituteInPlace "./XADMaster.xcodeproj/project.pbxproj" \
+        --replace "libstdc++.6.dylib" "libc++.1.dylib"
+    '' else ''
+      for f in Makefile.linux ../UniversalDetector/Makefile.linux ; do
+        substituteInPlace $f \
+          --replace "= gcc" "=${stdenv.cc.targetPrefix}cc" \
+          --replace "= g++" "=${stdenv.cc.targetPrefix}c++" \
+          --replace "-DGNU_RUNTIME=1" "" \
+          --replace "-fgnu-runtime" "-fobjc-nonfragile-abi"
+      done
 
-    # we need to build inside this directory as well, so we have to make it writeable
-    chmod +w ../UniversalDetector -R
-  '';
+      # we need to build inside this directory as well, so we have to make it writeable
+      chmod +w ../UniversalDetector -R
+    '';
 
-  buildInputs = [ gnustep.base bzip2 icu openssl wavpack zlib ];
+  buildInputs = [ bzip2 icu openssl wavpack zlib ] ++
+    lib.optionals stdenv.isLinux [ gnustep.base ] ++
+    lib.optionals stdenv.isDarwin [ Foundation AppKit ];
 
-  nativeBuildInputs = [ gnustep.make installShellFiles ];
+  nativeBuildInputs = [ installShellFiles ] ++
+    lib.optionals stdenv.isLinux [ gnustep.make ] ++
+    lib.optionals stdenv.isDarwin [ xcbuildHook ];
+
+  xcbuildFlags = lib.optionals stdenv.isDarwin [
+    "-target unar"
+    "-target lsar"
+    "-configuration Release"
+    "MACOSX_DEPLOYMENT_TARGET=10.12"
+    # Fix "ld: file not found: /nix/store/*-clang-7.1.0/lib/arc/libarclite_macosx." error
+    # Disabling ARC may leak memory, however since this program is generally not used for
+    # long periods of time, it shouldn't be an issue
+    "CLANG_LINK_OBJC_RUNTIME=NO"
+  ];
+
+  makefile = lib.optionalString (!stdenv.isDarwin) "Makefile.linux";
 
   enableParallelBuilding = true;
 
   dontConfigure = true;
 
-  makefile = "Makefile.linux";
-
   sourceRoot = "./source/XADMaster";
 
   installPhase = ''
     runHook preInstall
 
-    install -Dm555 -t $out/bin lsar unar
+    install -Dm555 -t $out/bin ${lib.optionalString stdenv.isDarwin "Products/Release/"}{lsar,unar}
     for f in lsar unar; do
       installManPage ./Extra/$f.?
       installShellCompletion --bash --name $f ./Extra/$f.bash_completion
@@ -60,7 +92,7 @@ stdenv.mkDerivation rec {
       ADF, DMS, LZX, PowerPacker, LBR, Squeeze, Crunch, and other old formats.
     '';
     license = licenses.lgpl21Plus;
-    maintainers = with maintainers; [ peterhoeg ];
-    platforms = platforms.linux;
+    maintainers = with maintainers; [ peterhoeg thiagokokada ];
+    platforms = platforms.unix;
   };
 }