From b57c104d0b4bcea51426271b32f18776d7667a72 Mon Sep 17 00:00:00 2001 From: Brian Leung Date: Tue, 6 Dec 2022 17:12:24 -0800 Subject: Revert "Revert "add tree sitter languages to rpath (#273)"" This reverts commit 1e4763dd90ad8712b459d1f5e53cbbc047b75dd0. --- overlays/emacs.nix | 23 ++++++++--------------- 1 file changed, 8 insertions(+), 15 deletions(-) (limited to 'overlays') diff --git a/overlays/emacs.nix b/overlays/emacs.nix index ab16a7250416..7731175a8bc7 100644 --- a/overlays/emacs.nix +++ b/overlays/emacs.nix @@ -83,7 +83,6 @@ let /usr/bin/codesign -s - -f $out/lib/${lib drv} '' else ''ln -s ${drv}/parser $out/lib/${lib drv}''; - linkerFlag = drv: "-l" + libName drv; plugins = with self.pkgs.tree-sitter-grammars; [ tree-sitter-bash tree-sitter-c @@ -101,20 +100,14 @@ let (super.lib.concatStringsSep "\n" (["mkdir -p $out/lib"] ++ (map linkCmd plugins))); in { buildInputs = old.buildInputs ++ [ self.pkgs.tree-sitter tree-sitter-grammars ]; - # before building the `.el` files, we need to allow the `tree-sitter` libraries - # bundled in emacs to be dynamically loaded. - TREE_SITTER_LIBS = super.lib.concatStringsSep " " ([ "-ltree-sitter" ] ++ (map linkerFlag plugins)); - # Add to directories that tree-sitter looks in for language definitions / shared object parsers - # FIXME: This was added for macOS, but it shouldn't be necessary on any platform. - # https://git.savannah.gnu.org/cgit/emacs.git/tree/src/treesit.c?h=64044f545add60e045ff16a9891b06f429ac935f#n533 - # appends a bunch of filenames that appear to be incorrectly skipped over - # in https://git.savannah.gnu.org/cgit/emacs.git/tree/src/treesit.c?h=64044f545add60e045ff16a9891b06f429ac935f#n567 - # on macOS, but are handled properly in Linux. - postPatch = old.postPatch + super.lib.optionalString super.stdenv.isDarwin '' - substituteInPlace src/treesit.c \ - --replace "Vtreesit_extra_load_path = Qnil;" \ - "Vtreesit_extra_load_path = list1 ( build_string ( \"${tree-sitter-grammars}/lib\" ) );" - ''; + TREE_SITTER_LIBS = "-ltree-sitter"; + # Add to list of directories dlopen/dynlib_open searches for tree sitter languages *.so/*.dylib. + postFixup = old.postFixup + super.lib.optionalString self.stdenv.isDarwin '' + /usr/bin/install_name_tool -add_rpath ${super.lib.makeLibraryPath [ tree-sitter-grammars ]} $out/bin/emacs + /usr/bin/codesign -s - -f $out/bin/emacs + '' + super.lib.optionalString self.stdenv.isLinux '' + ${self.pkgs.patchelf}/bin/patchelf --add-rpath ${super.lib.makeLibraryPath [ tree-sitter-grammars ]} $out/bin/emacs + ''; } ) ))); -- cgit 1.4.1