branch: elpa/nix-mode
commit d6e895969bc731d92a530ab17045baf2521aca6e
Author: yilinwei <[email protected]>
Commit: yilinwei <[email protected]>

    Set the 'LD_LIBRARY_PATH' environment variable for mkShell
    
    This relies on the 'LD_LIBRARY_PATH' attribute in the
    mkShell derivation and won't work for other commonly
    used methods such as setting the 'shellHook' attribute.
---
 nix-shell.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/nix-shell.el b/nix-shell.el
index c6d23e0c04..ba755db2f7 100644
--- a/nix-shell.el
+++ b/nix-shell.el
@@ -131,7 +131,9 @@ The DRV file to use."
                         (apply 'append
                                (mapcar (lambda (prop)
                                          (split-string (alist-get prop env)))
-                                       nix-shell-inputs)))))
+                                       nix-shell-inputs))))
+        ;; This attribute is in `mkShell' — ideally, we'd only check this 
variable in those cases.
+        (ld-library-path (alist-get 'LD_LIBRARY_PATH env)))
 
     ;; Prevent accidentally rebuilding the world.
     (unless (file-directory-p stdenv)
@@ -152,6 +154,13 @@ The DRV file to use."
        ;; (setq-local process-environment nil)
        )
 
+      ;; Set the LD_LIBRARY_PATH where applicable
+      (when ld-library-path
+       (make-local-variable 'process-environment)
+       (setq process-environment
+             (cons (format "LD_LIBRARY_PATH=%s" ld-library-path)
+                   process-environment)))
+
       (dolist (input inputs)
        (when (and (not (file-directory-p input))
                   nix-shell-auto-realise)

Reply via email to