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