From 2430837315cfb9d2d0cbc7002ee9a1e8e9b63417 Mon Sep 17 00:00:00 2001 From: Andreas Fuchs Date: Sun, 1 Jan 2023 19:52:38 -0500 Subject: Use build flags to add tree-sitter-grammars to RPATH on Darwin It seems that on Darwin, adding the second rpath entry after build doesn't cause dlopen to search in that rpath entry: It might be because the code signature block is in the way. At any rate, this way works on Darwin. --- overlays/emacs.nix | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'overlays') diff --git a/overlays/emacs.nix b/overlays/emacs.nix index 9bf46eff2e2e..2e3a12d3cf5c 100644 --- a/overlays/emacs.nix +++ b/overlays/emacs.nix @@ -113,12 +113,11 @@ let (super.lib.concatStringsSep "\n" (["mkdir -p $out/lib"] ++ (map linkCmd plugins))); in { buildInputs = old.buildInputs ++ [ self.pkgs.tree-sitter tree-sitter-grammars ]; + buildFlags = super.lib.optionalString self.stdenv.isDarwin + "LDFLAGS=-Wl,-rpath,${super.lib.makeLibraryPath [tree-sitter-grammars]}"; 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 '' - 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 '' + # Add to list of directories dlopen/dynlib_open searches for tree sitter languages *.so + postFixup = old.postFixup + 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