Merge pull request #308348 from RyanGibb/notmuch-vim

notmuch: install the vim plugin
This commit is contained in:
Doron Behar 2024-05-05 10:24:38 +03:00 committed by GitHub
commit 3f7095163e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1,4 +1,4 @@
{ fetchurl, lib, stdenv, makeWrapper { fetchurl, lib, stdenv, makeWrapper, buildEnv
, pkg-config, gnupg , pkg-config, gnupg
, xapian, gmime3, sfsexp, talloc, zlib , xapian, gmime3, sfsexp, talloc, zlib
, doxygen, perl, texinfo , doxygen, perl, texinfo
@ -12,14 +12,15 @@
, withEmacs ? true , withEmacs ? true
, withRuby ? true , withRuby ? true
, withSfsexp ? true # also installs notmuch-git, which requires sexp-support , withSfsexp ? true # also installs notmuch-git, which requires sexp-support
, withVim ? true
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation (finalAttrs: {
pname = "notmuch"; pname = "notmuch";
version = "0.38.3"; version = "0.38.3";
src = fetchurl { 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="; hash = "sha256-mvRsyA2li0MByiuu/MJaQNES0DFVB+YywPPw8IMo0FQ=";
}; };
@ -76,8 +77,7 @@ stdenv.mkDerivation rec {
''; '';
outputs = [ "out" "man" "info" "bindingconfig" ] outputs = [ "out" "man" "info" "bindingconfig" ]
++ lib.optional withEmacs "emacs" ++ lib.optional withEmacs "emacs";
++ lib.optional withRuby "ruby";
# if notmuch is built with s-expression support, the testsuite (T-850.sh) only # 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. # 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 moveToOutput bin/notmuch-emacs-mua $emacs
'' + lib.optionalString withRuby '' '' + lib.optionalString withRuby ''
make -C bindings/ruby install \ make -C bindings/ruby install \
vendordir=$ruby/lib/ruby \ vendordir=$out/lib/ruby \
SHELL=$SHELL \ SHELL=$SHELL \
$makeFlags "''${makeFlagsArray[@]}" \ $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}" $installFlags "''${installFlagsArray[@]}"
@ -133,12 +133,31 @@ stdenv.mkDerivation rec {
+ lib.optionalString withSfsexp '' + lib.optionalString withSfsexp ''
cp notmuch-git $out/bin/notmuch-git cp notmuch-git $out/bin/notmuch-git
wrapProgram $out/bin/notmuch-git --prefix PATH : $out/bin:${lib.getBin git}/bin 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 = { 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; }; tests.version = testers.testVersion { package = notmuch; };
inherit version;
updateScript = gitUpdater { updateScript = gitUpdater {
url = "https://git.notmuchmail.org/git/notmuch"; url = "https://git.notmuchmail.org/git/notmuch";
@ -155,4 +174,4 @@ stdenv.mkDerivation rec {
platforms = platforms.unix; platforms = platforms.unix;
mainProgram = "notmuch"; mainProgram = "notmuch";
}; };
} })