How to set an Emacs Lisp variable value to a binary provided by package from emacsPackages if the binary is not in `$PATH`

Given I installed an Emacs package with Nix (e.g. emacs28Packages.pdf-tools), how set an Emacs Lisp variable (e.g. pdf-info-epdfinfo-program) pointing to the executable (e.g. /nix/store/mx3rg8a3f9zqw0clqgb3y466wvyr8qnv-emacs-pdf-tools-20220214.344/share/emacs/site-lisp/elpa/pdf-tools-20220214.344/epdfinfo) if the package doesn’t link the binary to bin or make it available in $PATH in another way? When it is in $PATH, I use the (file-truename (executable-find executable-name)) to find it’s actual path in /nix/store and set it.

Besides epdfinfo, I also have this issue emacsql-sqlite (emacsql-sqlite-executable).

You have a few different options:

  1. have home-manager write out a file in a known path (in my case $XDG_CONFIG_HOME/doom/home-manager.el) that does the setq bits for the various binaries. Then load it from your config.
  2. alternatively, create a wrapper for launching emacs that injects the various binaries into the path and the various emacs components will then auto-detect the binaries since they are on the $PATH.
2 Likes

There was this in earlier thread, I’ll try once back at my machine: How can I get Emacs pdf-tools working? - #7 by JonathanReeve

1 Like

@peterhoeg @payas thank you both very much, both solutions worked!

(Unfortunately it doesn’t seem to be possible to mark both replies as solutions)

1 Like

I nominate @peterhoeg 's solution as it applies non-doom configs as well.

1 Like
Hosted by Flying Circus.