about summary refs log tree commit diff
path: root/pkgs/by-name/un/unrar/package.nix
blob: ea97195c2ae36c660b991b2cc523c042e5602185 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{ lib
, stdenv
, fetchzip
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "unrar";
  version = "7.0.7";

  src = fetchzip {
    url = "https://www.rarlab.com/rar/unrarsrc-${finalAttrs.version}.tar.gz";
    stripRoot = false;
    hash = "sha256-S7BMywydetDh1GINcK3k3fN9ciDoKTCAe/1tkgykoAQ=";
  };

  sourceRoot = finalAttrs.src.name;

  postPatch = ''
    substituteInPlace unrar/makefile \
      --replace "CXX=" "#CXX=" \
      --replace "STRIP=" "#STRIP=" \
      --replace "AR=" "#AR="
  '';

  outputs = [ "out" "dev" ];

  # `make {unrar,lib}` call `make clean` implicitly
  # separate build into different dirs to avoid deleting them
  buildPhase = ''
    runHook preBuild

    cp -a unrar libunrar
    make -C libunrar lib
    make -C unrar -j1

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    install -Dm755 unrar/unrar -t $out/bin/
    install -Dm644 unrar/{acknow.txt,license.txt} -t $out/share/doc/unrar/

    install -Dm755 libunrar/libunrar.so -t $out/lib/
    install -Dm644 libunrar/dll.hpp -t $dev/include/unrar/

    runHook postInstall
  '';

  setupHook = ./setup-hook.sh;

  meta = with lib; {
    description = "Utility for RAR archives";
    homepage = "https://www.rarlab.com/";
    license = licenses.unfreeRedistributable;
    mainProgram = "unrar";
    maintainers = with maintainers; [ wegank ];
    platforms = platforms.all;
  };
})