nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 fetchFromGitHub,
4 gettext,
5 xorg, # for lndir
6 gtk3,
7 python3Packages,
8 gdk-pixbuf,
9 libnotify,
10 gst_all_1,
11 libsecret,
12 wrapGAppsHook3,
13 gsettings-desktop-schemas,
14 glib,
15 gobject-introspection,
16 # Available plugins (can be overridden)
17 availablePlugins,
18 # Used in the withPlugins interface at passthru, can be overrided directly, or
19 # preferably via e.g: `mailnag.withPlugins([mailnag.availablePlugins.goa])`
20 mailnag,
21 userPlugins ? [ ],
22 pluginsDeps ? [ ],
23}:
24
25python3Packages.buildPythonApplication rec {
26 pname = "mailnag";
27 version = "2.2.0";
28 format = "setuptools";
29
30 src = fetchFromGitHub {
31 owner = "pulb";
32 repo = "mailnag";
33 rev = "v${version}";
34 sha256 = "0m1cyzwzm7z4p2v31dx098a1iar7dbilwyjcxiqnjx05nlmiqvgf";
35 };
36
37 buildInputs = [
38 gtk3
39 gdk-pixbuf
40 glib
41 libnotify
42 gst_all_1.gstreamer
43 gst_all_1.gst-plugins-base
44 gst_all_1.gst-plugins-good
45 gst_all_1.gst-plugins-bad
46 libsecret
47 ]
48 ++ pluginsDeps;
49
50 nativeBuildInputs = [
51 gettext
52 wrapGAppsHook3
53 gobject-introspection
54 # To later add plugins to
55 xorg.lndir
56 ];
57
58 propagatedBuildInputs = with python3Packages; [
59 gsettings-desktop-schemas
60 pygobject3
61 dbus-python
62 pyxdg
63 ];
64
65 passthru = {
66 inherit availablePlugins;
67 withPlugins =
68 plugs:
69 let
70 # goa plugin requires gio's gnome-online-accounts which requires making sure
71 # mailnag runs with GI_TYPELIB_PATH containing the path to Goa-1.0.typelib.
72 # This is handled best by adding the plugins' deps to buildInputs and let
73 # wrapGAppsHook3 handle that.
74 pluginsDeps = lib.flatten (lib.catAttrs "buildInputs" plugs);
75 self = mailnag;
76 in
77 self.override {
78 userPlugins = plugs;
79 inherit pluginsDeps;
80 };
81 };
82
83 # See https://nixos.org/nixpkgs/manual/#ssec-gnome-common-issues-double-wrapped
84 dontWrapGApps = true;
85
86 preFixup = ''
87 substituteInPlace $out/${python3Packages.python.sitePackages}/Mailnag/common/dist_cfg.py \
88 --replace "/usr/" $out/
89 for desktop_file in $out/share/applications/*.desktop; do
90 substituteInPlace "$desktop_file" \
91 --replace "/usr/bin" $out/bin
92 done
93 makeWrapperArgs+=("''${gappsWrapperArgs[@]}")
94 '';
95
96 # Actually install plugins
97 postInstall = ''
98 for plug in ${builtins.toString userPlugins}; do
99 lndir $plug/${python3Packages.python.sitePackages} $out/${python3Packages.python.sitePackages}
100 done
101 '';
102
103 meta = with lib; {
104 description = "Extensible mail notification daemon";
105 homepage = "https://github.com/pulb/mailnag";
106 license = licenses.gpl2;
107 platforms = platforms.linux;
108 maintainers = with maintainers; [ doronbehar ];
109 broken = true; # at 2022-09-23
110 };
111}