31 withSfsexp ? true, # also installs notmuch-git, which requires sexp-support
32 # TODO upstream: it takes too long ! 800 ms here
36 stdenv.mkDerivation (finalAttrs: {
41 url = "https://notmuchmail.org/releases/notmuch-${finalAttrs.version}.tar.xz";
42 hash = "sha256-mvRsyA2li0MByiuu/MJaQNES0DFVB+YywPPw8IMo0FQ=";
48 doxygen # (optional) api docs
49 pythonPackages.sphinx # (optional) documentation -> doc/INSTALL
50 texinfo # (optional) documentation -> doc/INSTALL
53 ++ lib.optional withEmacs emacs
54 ++ lib.optional withRuby ruby
55 ++ lib.optional withSfsexp makeWrapper;
59 gnupg # undefined dependencies
63 zlib # dependencies described in INSTALL
67 ++ lib.optional withRuby ruby
68 ++ lib.optional withSfsexp sfsexp;
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"' ""
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'
89 "--zshcompletiondir=${placeholder "out"}/share/zsh/site-functions"
90 "--bashcompletiondir=${placeholder "out"}/share/bash-completion/completions"
91 "--infodir=${placeholder "info"}/share/info"
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
99 setOutputFlags = false;
100 enableParallelBuilding = true;
101 makeFlags = [ "V=1" ];
104 mkdir ${placeholder "bindingconfig"}
105 cp bindings/python-cffi/_notmuch_config.py ${placeholder "bindingconfig"}/
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
126 test-database = fetchurl {
127 url = "https://notmuchmail.org/releases/test-databases/database-v1.tar.xz";
128 sha256 = "1lk91s00y4qy4pjh8638b5lfkgwyl282g1m27srsf7qfn58y16a2";
132 mkdir -p test/test-databases
133 ln -s ${test-database} test/test-databases/database-v1.tar.xz
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
145 doCheck = !stdenv.hostPlatform.isDarwin && (lib.versionAtLeast gmime3.version "3.0.3");
146 checkTarget = "test";
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;
168 lib.optionalString withEmacs ''
169 moveToOutput bin/notmuch-emacs-mua $emacs
171 + lib.optionalString withRuby ''
172 make -C bindings/ruby install \
173 vendordir=$out/lib/ruby \
175 $makeFlags "''${makeFlagsArray[@]}" \
176 $installFlags "''${installFlagsArray[@]}"
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
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
189 + lib.optionalString (withVim && withRuby) ''
190 PLUG=$vim/share/vim-plugins/notmuch/plugin/notmuch.vim
192 let \$GEM_PATH=\$GEM_PATH . ":${finalAttrs.passthru.gemEnv}/${ruby.gemPath}"
193 let \$RUBYLIB=\$RUBYLIB . ":$vim/${ruby.libPath}/${ruby.system}"
196 for gem in ${finalAttrs.passthru.gemEnv}/${ruby.gemPath}/gems/*/lib; do
197 echo "ruby \$LOAD_PATH.unshift('$gem')" >> $PLUG
199 echo 'endif' >> $PLUG
203 pythonSourceRoot = "notmuch-${finalAttrs.version}/bindings/python";
205 name = "notmuch-vim-gems";
206 paths = with ruby.gems; [ mail ];
212 tests.version = testers.testVersion { package = finalAttrs.finalPackage; };
214 updateScript = gitUpdater {
215 url = "https://git.notmuchmail.org/git/notmuch";
216 ignoredVersions = "_(rc|pre).*";
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; [
229 platforms = platforms.unix;
230 mainProgram = "notmuch";