about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/un/unrar
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/by-name/un/unrar')
-rw-r--r--nixpkgs/pkgs/by-name/un/unrar/package.nix61
-rw-r--r--nixpkgs/pkgs/by-name/un/unrar/setup-hook.sh5
2 files changed, 66 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/un/unrar/package.nix b/nixpkgs/pkgs/by-name/un/unrar/package.nix
new file mode 100644
index 000000000000..ea97195c2ae3
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/un/unrar/package.nix
@@ -0,0 +1,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;
+  };
+})
diff --git a/nixpkgs/pkgs/by-name/un/unrar/setup-hook.sh b/nixpkgs/pkgs/by-name/un/unrar/setup-hook.sh
new file mode 100644
index 000000000000..41d6a5cd217b
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/un/unrar/setup-hook.sh
@@ -0,0 +1,5 @@
+unpackCmdHooks+=(_tryUnrar)
+_tryUnrar() {
+    if ! [[ "$curSrc" =~ \.rar$ ]]; then return 1; fi
+    unrar x "$curSrc" >/dev/null
+}