1{
2 lib,
3 rustPlatform,
4 fetchFromGitHub,
5 installShellFiles,
6 pkg-config,
7 bzip2,
8 bzip3,
9 xz,
10 git,
11 zlib,
12 zstd,
13
14 # RAR code is under non-free unRAR license
15 # see the meta.license section below for more details
16 enableUnfree ? false,
17}:
18
19rustPlatform.buildRustPackage rec {
20 pname = "ouch";
21 version = "0.6.1";
22
23 src = fetchFromGitHub {
24 owner = "ouch-org";
25 repo = "ouch";
26 rev = version;
27 hash = "sha256-vNeOJOyQsjDUzScA1a/W+SI1Z67HTLiHjwWZZpr1Paw=";
28 };
29
30 cargoHash = "sha256-mMoYJ3dLpb1Y3Ocdyxg1brE7xYeZBbtUg0J/2HTK0hE=";
31
32 nativeBuildInputs = [
33 installShellFiles
34 pkg-config
35 rustPlatform.bindgenHook
36 ];
37
38 nativeCheckInputs = [
39 git
40 ];
41
42 buildInputs = [
43 bzip2
44 bzip3
45 xz
46 zlib
47 zstd
48 ];
49
50 buildNoDefaultFeatures = true;
51 buildFeatures = [
52 "use_zlib"
53 "use_zstd_thin"
54 # "bzip3" will be optional in the next version
55 "zstd/pkg-config"
56 ]
57 ++ lib.optionals enableUnfree [
58 "unrar"
59 ];
60
61 postInstall = ''
62 installManPage artifacts/*.1
63 installShellCompletion artifacts/ouch.{bash,fish} --zsh artifacts/_ouch
64 '';
65
66 env.OUCH_ARTIFACTS_FOLDER = "artifacts";
67
68 meta = {
69 description = "Command-line utility for easily compressing and decompressing files and directories";
70 homepage = "https://github.com/ouch-org/ouch";
71 changelog = "https://github.com/ouch-org/ouch/blob/${version}/CHANGELOG.md";
72 license = with lib.licenses; [ mit ] ++ lib.optionals enableUnfree [ unfreeRedistributable ];
73 maintainers = with lib.maintainers; [
74 figsoda
75 psibi
76 krovuxdev
77 ];
78 mainProgram = "ouch";
79 };
80}