about summary refs log tree commit diff
path: root/pkgs/tools/archivers/peazip/default.nix
blob: e99aa5f27495e7456a64e5f725c8f1dcc7bb49ae (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
{ stdenv
, lib
, fetchFromGitHub
, wrapQtAppsHook
, fpc
, lazarus
, xorg
, libqt5pas
, runCommand
, _7zz
, archiver
, brotli
, upx
, zpaq
, zstd
}:

stdenv.mkDerivation rec {
  pname = "peazip";
  version = "9.8.0";

  src = fetchFromGitHub {
    owner = "peazip";
    repo = pname;
    rev = version;
    hash = "sha256-oHtxiunB409xwk4tYB336Bq51Fl7PFrXKwH7ySaYCEs=";
  };
  sourceRoot = "${src.name}/peazip-sources";

  postPatch = ''
    # set it to use compression programs from $PATH
    substituteInPlace dev/peach.pas --replace "  HSYSBIN       = 0;" "  HSYSBIN       = 2;"
  '';

  nativeBuildInputs = [
    wrapQtAppsHook
    lazarus
    fpc
  ];

  buildInputs = [
    xorg.libX11
    libqt5pas
  ];

  NIX_LDFLAGS = "--as-needed -rpath ${lib.makeLibraryPath buildInputs}";

  buildPhase = ''
    # lazarus tries to create files in $HOME/.lazarus
    export HOME=$(mktemp -d)
    pushd dev
    lazbuild --lazarusdir=${lazarus}/share/lazarus --add-package metadarkstyle/metadarkstyle.lpk
    lazbuild --lazarusdir=${lazarus}/share/lazarus --widgetset=qt5 --build-all project_pea.lpi
    lazbuild --lazarusdir=${lazarus}/share/lazarus --widgetset=qt5 --build-all project_peach.lpi
    popd
  '';

  # peazip looks for the "7z", not "7zz"
  _7z = runCommand "7z" {} ''
    mkdir -p $out/bin
    ln -s ${_7zz}/bin/7zz $out/bin/7z
  '';

  installPhase = ''
    runHook preInstall

    install -D dev/{pea,peazip} -t $out/lib/peazip
    wrapProgram $out/lib/peazip/peazip --prefix PATH : ${lib.makeBinPath [
      _7z
      archiver
      brotli
      upx
      zpaq
      zstd
    ]}
    mkdir -p $out/bin
    ln -s $out/lib/peazip/{pea,peazip} $out/bin/

    mkdir -p $out/share/peazip $out/lib/peazip/res/share
    ln -s $out/share/peazip $out/lib/peazip/res/share
    cp -r res/share/{icons,lang,themes,presets} $out/share/peazip/
    # Install desktop entries
    install -D res/share/batch/freedesktop_integration/*.desktop -t $out/share/applications
    # Install desktop entries's icons
    mkdir -p $out/share/icons/hicolor/256x256/apps
    ln -s $out/share/peazip/icons/peazip.png -t $out/share/icons/hicolor/256x256/apps/
    mkdir $out/share/icons/hicolor/256x256/mimetypes
    ln -s $out/share/peazip/icons/peazip_{7z,zip,cd}.png $out/share/icons/hicolor/256x256/mimetypes/
    mkdir $out/share/icons/hicolor/256x256/actions
    ln -s $out/share/peazip/icons/peazip_{add,extract,convert}.png $out/share/icons/hicolor/256x256/actions/

    runHook postInstall
  '';

  meta = with lib; {
    description = "Cross-platform file and archive manager";
    longDescription = ''
      Free Zip / Unzip software and Rar file extractor. Cross-platform file and archive manager.

      Features volume spanning, compression, authenticated encryption.

      Supports 7Z, 7-Zip sfx, ACE, ARJ, Brotli, BZ2, CAB, CHM, CPIO, DEB, GZ, ISO, JAR, LHA/LZH, NSIS, OOo, PEA, RAR, RPM, split, TAR, Z, ZIP, ZIPX, Zstandard.
    '';
    license = licenses.gpl3Only;
    homepage = "https://peazip.github.io";
    platforms = platforms.linux;
    maintainers = with maintainers; [ annaaurora ];
    mainProgram = "peazip";
  };
}