about summary refs log tree commit diff
path: root/pkgs/applications/networking/mailreaders/notmuch/default.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/applications/networking/mailreaders/notmuch/default.nix')
-rw-r--r--pkgs/applications/networking/mailreaders/notmuch/default.nix37
1 files changed, 28 insertions, 9 deletions
diff --git a/pkgs/applications/networking/mailreaders/notmuch/default.nix b/pkgs/applications/networking/mailreaders/notmuch/default.nix
index ba2f75669847c..588cd4326a61e 100644
--- a/pkgs/applications/networking/mailreaders/notmuch/default.nix
+++ b/pkgs/applications/networking/mailreaders/notmuch/default.nix
@@ -1,4 +1,4 @@
-{ fetchurl, lib, stdenv, makeWrapper
+{ fetchurl, lib, stdenv, makeWrapper, buildEnv
 , pkg-config, gnupg
 , xapian, gmime3, sfsexp, talloc, zlib
 , doxygen, perl, texinfo
@@ -12,14 +12,15 @@
 , withEmacs ? true
 , withRuby ? true
 , withSfsexp ? true # also installs notmuch-git, which requires sexp-support
+, withVim ? true
 }:
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (finalAttrs: {
   pname = "notmuch";
   version = "0.38.3";
 
   src = fetchurl {
-    url = "https://notmuchmail.org/releases/notmuch-${version}.tar.xz";
+    url = "https://notmuchmail.org/releases/notmuch-${finalAttrs.version}.tar.xz";
     hash = "sha256-mvRsyA2li0MByiuu/MJaQNES0DFVB+YywPPw8IMo0FQ=";
   };
 
@@ -76,8 +77,7 @@ stdenv.mkDerivation rec {
   '';
 
   outputs = [ "out" "man" "info" "bindingconfig" ]
-    ++ lib.optional withEmacs "emacs"
-    ++ lib.optional withRuby "ruby";
+    ++ lib.optional withEmacs "emacs";
 
   # if notmuch is built with s-expression support, the testsuite (T-850.sh) only
   # passes if notmuch-git can be executed, so we need to patch its shebang.
@@ -123,7 +123,7 @@ stdenv.mkDerivation rec {
     moveToOutput bin/notmuch-emacs-mua $emacs
   '' + lib.optionalString withRuby ''
     make -C bindings/ruby install \
-      vendordir=$ruby/lib/ruby \
+      vendordir=$out/lib/ruby \
       SHELL=$SHELL \
       $makeFlags "''${makeFlagsArray[@]}" \
       $installFlags "''${installFlagsArray[@]}"
@@ -133,12 +133,31 @@ stdenv.mkDerivation rec {
   + lib.optionalString withSfsexp ''
     cp notmuch-git $out/bin/notmuch-git
     wrapProgram $out/bin/notmuch-git --prefix PATH : $out/bin:${lib.getBin git}/bin
+  '' + lib.optionalString withVim ''
+    make -C vim DESTDIR="$out/share/vim-plugins/notmuch" prefix="" install
+    mkdir -p $out/share/nvim
+    ln -s $out/share/vim-plugins/notmuch $out/share/nvim/site
+  '' + lib.optionalString (withVim && withRuby) ''
+    PLUG=$out/share/vim-plugins/notmuch/plugin/notmuch.vim
+    cat >> $PLUG << EOF
+      let \$GEM_PATH=\$GEM_PATH . ":${finalAttrs.passthru.gemEnv}/${ruby.gemPath}"
+      let \$RUBYLIB=\$RUBYLIB . ":$out/${ruby.libPath}/${ruby.system}"
+      if has('nvim')
+    EOF
+    for gem in ${finalAttrs.passthru.gemEnv}/${ruby.gemPath}/gems/*/lib; do
+      echo "ruby \$LOAD_PATH.unshift('$gem')" >> $PLUG
+    done
+    echo 'endif' >> $PLUG
   '';
 
   passthru = {
-    pythonSourceRoot = "notmuch-${version}/bindings/python";
+    pythonSourceRoot = "notmuch-${finalAttrs.version}/bindings/python";
+    gemEnv = buildEnv {
+      name = "notmuch-vim-gems";
+      paths = with ruby.gems; [ mail ];
+      pathsToLink = [ "/lib" "/nix-support" ];
+    };
     tests.version = testers.testVersion { package = notmuch; };
-    inherit version;
 
     updateScript = gitUpdater {
       url = "https://git.notmuchmail.org/git/notmuch";
@@ -155,4 +174,4 @@ stdenv.mkDerivation rec {
     platforms   = platforms.unix;
     mainProgram = "notmuch";
   };
-}
+})