lol
1{ lib
2, stdenv
3, fetchFromGitHub
4, installShellFiles
5, gnustep
6, bzip2
7, zlib
8, icu
9, openssl
10, wavpack
11, xcbuildHook
12, Foundation
13, AppKit
14}:
15
16stdenv.mkDerivation rec {
17 pname = "unar";
18 version = "1.10.7";
19
20 src = fetchFromGitHub {
21 owner = "MacPaw";
22 # the unar repo contains a shallow clone of both XADMaster and universal-detector
23 repo = "unar";
24 rev = "v${version}";
25 sha256 = "0p846q1l66k3rnd512sncp26zpv411b8ahi145sghfcsz9w8abc4";
26 };
27
28 postPatch =
29 if stdenv.isDarwin then ''
30 substituteInPlace "./XADMaster.xcodeproj/project.pbxproj" \
31 --replace "libstdc++.6.dylib" "libc++.1.dylib"
32 '' else ''
33 for f in Makefile.linux ../UniversalDetector/Makefile.linux ; do
34 substituteInPlace $f \
35 --replace "= gcc" "=${stdenv.cc.targetPrefix}cc" \
36 --replace "= g++" "=${stdenv.cc.targetPrefix}c++" \
37 --replace "-DGNU_RUNTIME=1" "" \
38 --replace "-fgnu-runtime" "-fobjc-runtime=gnustep-2.0"
39 done
40
41 # we need to build inside this directory as well, so we have to make it writeable
42 chmod +w ../UniversalDetector -R
43 '';
44
45 buildInputs = [ bzip2 icu openssl wavpack zlib ] ++
46 lib.optionals stdenv.isLinux [ gnustep.base ] ++
47 lib.optionals stdenv.isDarwin [ Foundation AppKit ];
48
49 nativeBuildInputs = [ installShellFiles ] ++
50 lib.optionals stdenv.isLinux [ gnustep.make ] ++
51 lib.optionals stdenv.isDarwin [ xcbuildHook ];
52
53 xcbuildFlags = lib.optionals stdenv.isDarwin [
54 "-target unar"
55 "-target lsar"
56 "-configuration Release"
57 "MACOSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}"
58 ];
59
60 makefile = lib.optionalString (!stdenv.isDarwin) "Makefile.linux";
61
62 enableParallelBuilding = true;
63
64 dontConfigure = true;
65
66 sourceRoot = "${src.name}/XADMaster";
67
68 installPhase = ''
69 runHook preInstall
70
71 install -Dm555 -t $out/bin ${lib.optionalString stdenv.isDarwin "Products/Release/"}{lsar,unar}
72 for f in lsar unar; do
73 installManPage ./Extra/$f.?
74 installShellCompletion --bash --name $f ./Extra/$f.bash_completion
75 done
76
77 runHook postInstall
78 '';
79
80 meta = with lib; {
81 homepage = "https://theunarchiver.com";
82 description = "An archive unpacker program";
83 longDescription = ''
84 The Unarchiver is an archive unpacker program with support for the popular
85 zip, RAR, 7z, tar, gzip, bzip2, LZMA, XZ, CAB, MSI, NSIS, EXE, ISO, BIN,
86 and split file formats, as well as the old Stuffit, Stuffit X, DiskDouble,
87 Compact Pro, Packit, cpio, compress (.Z), ARJ, ARC, PAK, ACE, ZOO, LZH,
88 ADF, DMS, LZX, PowerPacker, LBR, Squeeze, Crunch, and other old formats.
89 '';
90 license = licenses.lgpl21Plus;
91 maintainers = with maintainers; [ peterhoeg ];
92 mainProgram = "unar";
93 platforms = platforms.unix;
94 };
95}