branch: elpa/nix-mode
commit 0380e03203db55d75fe94c8473eaa761dd870c99
Merge: 7593b023a7 aae6f710e0
Author: Matthew Bauer <[email protected]>
Commit: GitHub <[email protected]>
Merge pull request #109 from yilinwei/master
Set the 'LD_LIBRARY_PATH' environment variable for mkShell
---
nix-shell.el | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/nix-shell.el b/nix-shell.el
index c6d23e0c04..1a996e3891 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,20 @@ 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
+ (let*
+ ((var "LD_LIBRARY_PATH")
+ (current-path (getenv var)))
+ (if current-path
+ ;; LD_LIBRARY_PATH defined in derivation takes precedence
+ (format "%s=%s:%s" var ld-library-path current-path)
+ (format "%s=%s" var ld-library-path)))
+ process-environment)))
+
(dolist (input inputs)
(when (and (not (file-directory-p input))
nix-shell-auto-realise)