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