Unverified Commit 3f709516 authored by Doron Behar's avatar Doron Behar Committed by GitHub
Browse files

Merge pull request #308348 from RyanGibb/notmuch-vim

notmuch: install the vim plugin
parents 3f855a3d 590bccee
Loading
Loading
Loading
Loading
+28 −9
Original line number Diff line number Diff line
{ 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";
  };
}
})