vacuum-go: 0.16.1 -> 0.16.2 (#380231)
[NixPkgs.git] / pkgs / applications / networking / mailreaders / notmuch / default.nix
blob90c0c98b400a722347fe7608a60e4fb0ad4dd61c
2   fetchurl,
3   lib,
4   stdenv,
5   makeWrapper,
6   buildEnv,
7   pkg-config,
8   gnupg,
9   xapian,
10   gmime3,
11   sfsexp,
12   talloc,
13   zlib,
14   doxygen,
15   perl,
16   texinfo,
17   pythonPackages,
18   emacs,
19   ruby,
20   testers,
21   gitUpdater,
22   which,
23   dtach,
24   openssl,
25   bash,
26   gdb,
27   man,
28   git,
29   withEmacs ? true,
30   withRuby ? true,
31   withSfsexp ? true, # also installs notmuch-git, which requires sexp-support
32   # TODO upstream: it takes too long ! 800 ms here
33   withVim ? true,
36 stdenv.mkDerivation (finalAttrs: {
37   pname = "notmuch";
38   version = "0.38.3";
40   src = fetchurl {
41     url = "https://notmuchmail.org/releases/notmuch-${finalAttrs.version}.tar.xz";
42     hash = "sha256-mvRsyA2li0MByiuu/MJaQNES0DFVB+YywPPw8IMo0FQ=";
43   };
45   nativeBuildInputs =
46     [
47       pkg-config
48       doxygen # (optional) api docs
49       pythonPackages.sphinx # (optional) documentation -> doc/INSTALL
50       texinfo # (optional) documentation -> doc/INSTALL
51       pythonPackages.cffi
52     ]
53     ++ lib.optional withEmacs emacs
54     ++ lib.optional withRuby ruby
55     ++ lib.optional withSfsexp makeWrapper;
57   buildInputs =
58     [
59       gnupg # undefined dependencies
60       xapian
61       gmime3
62       talloc
63       zlib # dependencies described in INSTALL
64       perl
65       pythonPackages.python
66     ]
67     ++ lib.optional withRuby ruby
68     ++ lib.optional withSfsexp sfsexp;
70   postPatch =
71     ''
72       patchShebangs configure test/
74       substituteInPlace lib/Makefile.local \
75         --replace '-install_name $(libdir)' "-install_name $out/lib"
77       # do not override CFLAGS of the Makefile created by mkmf
78       substituteInPlace bindings/Makefile.local \
79         --replace 'CFLAGS="$(CFLAGS) -pipe -fno-plt -fPIC"' ""
80     ''
81     + lib.optionalString withEmacs ''
82       substituteInPlace emacs/notmuch-emacs-mua \
83         --replace 'EMACS:-emacs' 'EMACS:-${emacs}/bin/emacs' \
84         --replace 'EMACSCLIENT:-emacsclient' 'EMACSCLIENT:-${emacs}/bin/emacsclient'
85     '';
87   configureFlags =
88     [
89       "--zshcompletiondir=${placeholder "out"}/share/zsh/site-functions"
90       "--bashcompletiondir=${placeholder "out"}/share/bash-completion/completions"
91       "--infodir=${placeholder "info"}/share/info"
92     ]
93     ++ lib.optional (!withEmacs) "--without-emacs"
94     ++ lib.optional withEmacs "--emacslispdir=${placeholder "emacs"}/share/emacs/site-lisp"
95     ++ lib.optional (!withRuby) "--without-ruby";
97   # Notmuch doesn't use autoconf and consequently doesn't tag --bindir and
98   # friends
99   setOutputFlags = false;
100   enableParallelBuilding = true;
101   makeFlags = [ "V=1" ];
103   postConfigure = ''
104     mkdir ${placeholder "bindingconfig"}
105     cp bindings/python-cffi/_notmuch_config.py ${placeholder "bindingconfig"}/
106   '';
108   outputs =
109     [
110       "out"
111       "man"
112       "info"
113       "bindingconfig"
114     ]
115     ++ lib.optional withEmacs "emacs"
116     ++ lib.optional withVim "vim";
118   # if notmuch is built with s-expression support, the testsuite (T-850.sh) only
119   # passes if notmuch-git can be executed, so we need to patch its shebang.
120   postBuild = lib.optionalString withSfsexp ''
121     patchShebangs notmuch-git
122   '';
124   preCheck =
125     let
126       test-database = fetchurl {
127         url = "https://notmuchmail.org/releases/test-databases/database-v1.tar.xz";
128         sha256 = "1lk91s00y4qy4pjh8638b5lfkgwyl282g1m27srsf7qfn58y16a2";
129       };
130     in
131     ''
132       mkdir -p test/test-databases
133       ln -s ${test-database} test/test-databases/database-v1.tar.xz
134     ''
135     + ''
136       # Issues since gnupg: 2.4.0 -> 2.4.1
137       rm test/{T350-crypto,T357-index-decryption}.sh
138       # Issues since pbr 6.0.0 bump (ModuleNotFoundError: No module named 'notmuch2')
139       rm test/T055-path-config.sh
140       # Flaky, seems to get its paths wrong sometimes (?)
141       # *ERROR*: Opening output file: Permission denied, /nix/store/bzy21v2cd5sq1djzwa9b19q08wpp9mm0-emacs-29.1/bin/OUTPUT
142       rm test/T460-emacs-tree.sh
143     '';
145   doCheck = !stdenv.hostPlatform.isDarwin && (lib.versionAtLeast gmime3.version "3.0.3");
146   checkTarget = "test";
147   nativeCheckInputs =
148     [
149       which
150       dtach
151       openssl
152       bash
153       gdb
154       man
155     ]
156     # for the test T-850.sh for notmuch-git, which is skipped when notmuch is
157     # built without sexp-support
158     ++ lib.optional withEmacs emacs
159     ++ lib.optional withSfsexp git;
161   installTargets = [
162     "install"
163     "install-man"
164     "install-info"
165   ];
167   postInstall =
168     lib.optionalString withEmacs ''
169       moveToOutput bin/notmuch-emacs-mua $emacs
170     ''
171     + lib.optionalString withRuby ''
172       make -C bindings/ruby install \
173         vendordir=$out/lib/ruby \
174         SHELL=$SHELL \
175         $makeFlags "''${makeFlagsArray[@]}" \
176         $installFlags "''${installFlagsArray[@]}"
177     ''
178     # notmuch-git (https://notmuchmail.org/doc/latest/man1/notmuch-git.html) does not work without
179     # sexp-support, so there is no point in installing if we're building without it.
180     + lib.optionalString withSfsexp ''
181       cp notmuch-git $out/bin/notmuch-git
182       wrapProgram $out/bin/notmuch-git --prefix PATH : $out/bin:${lib.getBin git}/bin
183     ''
184     + lib.optionalString withVim ''
185       make -C vim DESTDIR="$vim/share/vim-plugins/notmuch" prefix="" install
186       mkdir -p $vim/share/nvim
187       ln -s $vim/share/vim-plugins/notmuch $vim/share/nvim/site
188     ''
189     + lib.optionalString (withVim && withRuby) ''
190       PLUG=$vim/share/vim-plugins/notmuch/plugin/notmuch.vim
191       cat >> $PLUG << EOF
192         let \$GEM_PATH=\$GEM_PATH . ":${finalAttrs.passthru.gemEnv}/${ruby.gemPath}"
193         let \$RUBYLIB=\$RUBYLIB . ":$vim/${ruby.libPath}/${ruby.system}"
194         if has('nvim')
195       EOF
196       for gem in ${finalAttrs.passthru.gemEnv}/${ruby.gemPath}/gems/*/lib; do
197         echo "ruby \$LOAD_PATH.unshift('$gem')" >> $PLUG
198       done
199       echo 'endif' >> $PLUG
200     '';
202   passthru = {
203     pythonSourceRoot = "notmuch-${finalAttrs.version}/bindings/python";
204     gemEnv = buildEnv {
205       name = "notmuch-vim-gems";
206       paths = with ruby.gems; [ mail ];
207       pathsToLink = [
208         "/lib"
209         "/nix-support"
210       ];
211     };
212     tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
214     updateScript = gitUpdater {
215       url = "https://git.notmuchmail.org/git/notmuch";
216       ignoredVersions = "_(rc|pre).*";
217     };
218   };
220   meta = with lib; {
221     description = "Mail indexer";
222     homepage = "https://notmuchmail.org/";
223     changelog = "https://git.notmuchmail.org/git?p=notmuch;a=blob_plain;f=NEWS;hb=${version}";
224     license = licenses.gpl3Plus;
225     maintainers = with maintainers; [
226       flokli
227       puckipedia
228     ];
229     platforms = platforms.unix;
230     mainProgram = "notmuch";
231   };