1{
2 lib,
3 stdenv,
4 buildPythonPackage,
5 pytestCheckHook,
6 fetchFromGitLab,
7 fetchpatch,
8 replaceVars,
9 bubblewrap,
10 exiftool,
11 ffmpeg,
12 setuptools,
13 wrapGAppsHook3,
14 gdk-pixbuf,
15 gobject-introspection,
16 librsvg,
17 poppler_gi,
18 mutagen,
19 pygobject3,
20 pycairo,
21 dolphinIntegration ? false,
22 kdePackages,
23}:
24
25buildPythonPackage rec {
26 pname = "mat2";
27 version = "0.13.5";
28 pyproject = true;
29
30 src = fetchFromGitLab {
31 domain = "0xacab.org";
32 owner = "jvoisin";
33 repo = "mat2";
34 tag = version;
35 hash = "sha256-ivFgH/88DBucZRaO/OMsLlwJCjv/VQXb6AiKWhZ8XH0=";
36 };
37
38 patches =
39 [
40 (fetchpatch {
41 name = "exiftool-13.25-compat.patch";
42 url = "https://0xacab.org/jvoisin/mat2/-/commit/473903b70e1b269a6110242a9c098a10c18554e2.patch";
43 hash = "sha256-vxxjAFwiTDlcTT3ZlfhOG4rlzBJS+LhLoA++8y2hEok=";
44 })
45 # hardcode paths to some binaries
46 (replaceVars ./paths.patch {
47 exiftool = lib.getExe exiftool;
48 ffmpeg = lib.getExe ffmpeg;
49 kdialog = if dolphinIntegration then lib.getExe kdePackages.kdialog else null;
50 # replaced in postPatch
51 mat2 = null;
52 mat2svg = null;
53 })
54 # the executable shouldn't be called .mat2-wrapped
55 ./executable-name.patch
56 # hardcode path to mat2 executable
57 ./tests.patch
58 ]
59 ++ lib.optionals (stdenv.hostPlatform.isLinux) [
60 (replaceVars ./bubblewrap-path.patch {
61 bwrap = lib.getExe bubblewrap;
62 })
63 ];
64
65 postPatch = ''
66 substituteInPlace dolphin/mat2.desktop \
67 --replace "@mat2@" "$out/bin/mat2" \
68 --replace "@mat2svg@" "$out/share/icons/hicolor/scalable/apps/mat2.svg"
69 '';
70
71 build-system = [ setuptools ];
72
73 nativeBuildInputs = [
74 gobject-introspection
75 wrapGAppsHook3
76 ];
77
78 buildInputs = [
79 gdk-pixbuf
80 librsvg
81 poppler_gi
82 ];
83
84 dependencies = [
85 mutagen
86 pygobject3
87 pycairo
88 ];
89
90 postInstall =
91 ''
92 install -Dm 444 data/mat2.svg -t "$out/share/icons/hicolor/scalable/apps"
93 install -Dm 444 doc/mat2.1 -t "$out/share/man/man1"
94 ''
95 + lib.optionalString dolphinIntegration ''
96 install -Dm 444 dolphin/mat2.desktop -t "$out/share/kservices5/ServiceMenus"
97 '';
98
99 nativeCheckInputs = [ pytestCheckHook ];
100
101 meta = with lib; {
102 description = "Handy tool to trash your metadata";
103 homepage = "https://0xacab.org/jvoisin/mat2";
104 changelog = "https://0xacab.org/jvoisin/mat2/-/blob/${version}/CHANGELOG.md";
105 license = licenses.lgpl3Plus;
106 mainProgram = "mat2";
107 maintainers = with maintainers; [ dotlambda ];
108 };
109}