1{ lib
2, stdenv
3, buildPythonPackage
4, unittestCheckHook
5, pythonOlder
6, fetchFromGitLab
7, fetchpatch
8, substituteAll
9, bubblewrap
10, exiftool
11, ffmpeg
12, mailcap
13, wrapGAppsHook
14, gdk-pixbuf
15, gobject-introspection
16, librsvg
17, poppler_gi
18, mutagen
19, pygobject3
20, pycairo
21, dolphinIntegration ? false
22, plasma5Packages
23}:
24
25buildPythonPackage rec {
26 pname = "mat2";
27 version = "0.13.0";
28
29 disabled = pythonOlder "3.5";
30
31 src = fetchFromGitLab {
32 domain = "0xacab.org";
33 owner = "jvoisin";
34 repo = "mat2";
35 rev = version;
36 hash = "sha256-H3l8w2F+ZcJ1P/Dg0ZVBJPUK0itLocL7a0jeSrG3Ws8=";
37 };
38
39 patches = [
40 # hardcode paths to some binaries
41 (substituteAll ({
42 src = ./paths.patch;
43 exiftool = "${exiftool}/bin/exiftool";
44 ffmpeg = "${ffmpeg}/bin/ffmpeg";
45 } // lib.optionalAttrs dolphinIntegration {
46 kdialog = "${plasma5Packages.kdialog}/bin/kdialog";
47 }))
48 # the executable shouldn't be called .mat2-wrapped
49 ./executable-name.patch
50 # hardcode path to mat2 executable
51 ./tests.patch
52 # fix gobject-introspection typelib path for Nautilus extension
53 (substituteAll {
54 src = ./fix_poppler.patch;
55 poppler_path = "${poppler_gi}/lib/girepository-1.0";
56 })
57 # https://0xacab.org/jvoisin/mat2/-/issues/178
58 (fetchpatch {
59 url = "https://0xacab.org/jvoisin/mat2/-/commit/618e0a8e3984fd534b95ef3dbdcb8a76502c90b5.patch";
60 hash = "sha256-l9UFim3hGj+d2uKITiDG1OnqGeo2McBIiRSmK0Vidg8=";
61 })
62 ] ++ lib.optionals (stdenv.hostPlatform.isLinux) [
63 (substituteAll {
64 src = ./bubblewrap-path.patch;
65 bwrap = "${bubblewrap}/bin/bwrap";
66 })
67 ];
68
69 postPatch = ''
70 substituteInPlace dolphin/mat2.desktop \
71 --replace "@mat2@" "$out/bin/mat2" \
72 --replace "@mat2svg@" "$out/share/icons/hicolor/scalable/apps/mat2.svg"
73 '';
74
75 nativeBuildInputs = [
76 gobject-introspection
77 wrapGAppsHook
78 ];
79
80 buildInputs = [
81 gdk-pixbuf
82 librsvg
83 poppler_gi
84 ];
85
86 propagatedBuildInputs = [
87 mutagen
88 pygobject3
89 pycairo
90 ];
91
92 postInstall = ''
93 install -Dm 444 data/mat2.svg -t "$out/share/icons/hicolor/scalable/apps"
94 install -Dm 444 doc/mat2.1 -t "$out/share/man/man1"
95 install -Dm 444 nautilus/mat2.py -t "$out/share/nautilus-python/extensions"
96 buildPythonPath "$out $pythonPath $propagatedBuildInputs"
97 patchPythonScript "$out/share/nautilus-python/extensions/mat2.py"
98 '' + lib.optionalString dolphinIntegration ''
99 install -Dm 444 dolphin/mat2.desktop -t "$out/share/kservices5/ServiceMenus"
100 '';
101
102 checkInputs = [ unittestCheckHook ];
103
104 unittestFlagsArray = [ "-v" ];
105
106 meta = with lib; {
107 description = "A handy tool to trash your metadata";
108 homepage = "https://0xacab.org/jvoisin/mat2";
109 changelog = "https://0xacab.org/jvoisin/mat2/-/blob/${version}/CHANGELOG.md";
110 license = licenses.lgpl3Plus;
111 maintainers = with maintainers; [ dotlambda ];
112 };
113}