lol
1{ lib, stdenv, fetchurl, autoPatchelfHook, installShellFiles }:
2
3let
4 version = "6.21";
5 downloadVersion = lib.replaceStrings [ "." ] [ "" ] version;
6 # Use `nix store prefetch-file <url>` to generate the hashes for the other systems
7 # TODO: create update script
8 srcUrl = {
9 i686-linux = {
10 url = "https://www.rarlab.com/rar/rarlinux-x32-${downloadVersion}.tar.gz";
11 hash = "sha256-mDeRmLTjF0ZLv4JoLrgI8YBFFulBSKfOPb6hrxDZIkU=";
12 };
13 x86_64-linux = {
14 url = "https://www.rarlab.com/rar/rarlinux-x64-${downloadVersion}.tar.gz";
15 hash = "sha256-3fr5aVkh/r6OfBEcZULJSZp5ydakJOLRPlgzMdlwGTM=";
16 };
17 aarch64-darwin = {
18 url = "https://www.rarlab.com/rar/rarmacos-arm-${downloadVersion}.tar.gz";
19 hash = "sha256-OR9HBlRteTzuyQ06tyXTSrFTBHFwmZ41kUfvgflogT4=";
20 };
21 x86_64-darwin = {
22 url = "https://www.rarlab.com/rar/rarmacos-x64-${downloadVersion}.tar.gz";
23 hash = "sha256-UN3gmEuIpCXwmw3/l+KdarAYLy1DxGoPAOB2bfJTGbw=";
24 };
25 }.${stdenv.system} or (throw "Unsupported system: ${stdenv.system}");
26 manSrc = fetchurl {
27 url = "https://aur.archlinux.org/cgit/aur.git/plain/rar.1?h=rar&id=8e39a12e88d8a3b168c496c44c18d443c876dd10";
28 name = "rar.1";
29 hash = "sha256-93cSr9oAsi+xHUtMsUvICyHJe66vAImS2tLie7nt8Uw=";
30 };
31in
32stdenv.mkDerivation rec {
33 pname = "rar";
34 inherit version;
35
36 src = fetchurl srcUrl;
37
38 dontBuild = true;
39
40 buildInputs = lib.optionals stdenv.isLinux [ stdenv.cc.cc.lib ];
41
42 nativeBuildInputs = [ installShellFiles ]
43 ++ lib.optionals stdenv.isLinux [ autoPatchelfHook ];
44
45 installPhase = ''
46 runHook preInstall
47
48 install -Dm755 {rar,unrar} -t "$out/bin"
49 install -Dm755 default.sfx -t "$out/lib"
50 install -Dm644 {acknow.txt,license.txt} -t "$out/share/doc/rar"
51 install -Dm644 rarfiles.lst -t "$out/etc"
52
53 runHook postInstall
54 '';
55
56 postInstall = ''
57 installManPage ${manSrc}
58 '';
59
60 meta = with lib; {
61 description = "Utility for RAR archives";
62 homepage = "https://www.rarlab.com/";
63 sourceProvenance = with sourceTypes; [ binaryNativeCode ];
64 license = licenses.unfree;
65 maintainers = with maintainers; [ thiagokokada ];
66 platforms = with platforms; linux ++ darwin;
67 };
68}