Subject: [PATCH 1/2] profiles: Add $GUIX_LIBRARY_PATH to default search paths.

From: [email-masked]
Date: Mon, 20 Jan 2025 20:06:50 +0800

From: 宋文武 <[email-masked]>

* guix/search-paths.scm ($GUIX_LIBRARY_PATH): New search path.
* guix/profiles.scm (manifest-search-paths): Add $GUIX_LIBRARY_PATH.
* guix/build/profiles.scm (manifest-sexp->inputs+search-paths): Add
$GUIX_LIBRARY_PATH.

Change-Id: I9ff090552bb40df7b42aaec71d587d3db07b20ed
---
 guix/build/profiles.scm |  1 +
 guix/profiles.scm       |  8 ++++----
 guix/search-paths.scm   | 10 ++++++++++
 3 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/guix/build/profiles.scm b/guix/build/profiles.scm
index b19d93f971..760b519bfa 100644
--- a/guix/build/profiles.scm
+++ b/guix/build/profiles.scm
@@ -180,6 +180,7 @@ (define (manifest-sexp->inputs+search-paths manifest)
           (values (reverse inputs)
                   (delete-duplicates
                    (cons* $PATH
+                          $GUIX_LIBRARY_PATH
                           $GUIX_EXTENSIONS_PATH
                           (map sexp->search-path-specification
                                (reverse search-paths)))))))))))
diff --git a/guix/profiles.scm b/guix/profiles.scm
index 87b9543ac0..f6ec51fe0b 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -742,11 +742,11 @@ (define (manifest-matching-entries manifest patterns)
 
 (define (manifest-search-paths manifest)
   "Return the list of search path specifications that apply to MANIFEST,
-including the search path specification for $PATH."
+including the search path specification for $PATH and $GUIX_LIBRARY_PATH."
   (delete-duplicates
-   (cons $PATH
-         (append-map manifest-entry-search-paths
-                     (manifest-entries manifest)))))
+   (cons* $PATH $GUIX_LIBRARY_PATH
+          (append-map manifest-entry-search-paths
+                      (manifest-entries manifest)))))
 
 (define* (manifest->code manifest
                          #:key (entry-package-version (const "")))
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index 27fcb78054..359ddc1750 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -40,6 +40,7 @@ (define-module (guix search-paths)
             $LIBRARY_PATH
             $GUIX_EXTENSIONS_PATH
             $PATH
+            $GUIX_LIBRARY_PATH
             $PKG_CONFIG_PATH
             $SSL_CERT_DIR
             $SSL_CERT_FILE
@@ -128,6 +129,15 @@ (define $PATH
    (variable "PATH")
    (files '("bin" "sbin"))))
 
+(define $GUIX_LIBRARY_PATH
+  ;; Set some environment variables can make a foreign system crash, eg:
+  ;;   GDK_PIXBUF_MODULE_FILE  <https://issues.guix.gnu.org/75523>
+  ;;   QT_PLUGIN_PATH          <https://issues.guix.gnu.org/73897>
+  ;; For those cases, we could patch softwares to use this special variable.
+  (search-path-specification
+   (variable "GUIX_LIBRARY_PATH")
+   (files '("lib"))))
+
 (define $GUIX_EXTENSIONS_PATH
   ;; 'GUIX_EXTENSIONS_PATH' is used by Guix to locate extension commands.
   ;; Unlike 'PATH', it is attached to a package, Guix; however, it is
-- 
2.47.1