Subject: [bug#45064] [PATCH 2/2] profiles: gtk-im-modules: Set environment variables for input methods.

From: [email-masked]
Date: Sun, 6 Dec 2020 14:15:15 +0800

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

* guix/profiles.scm (gtk-im-modules): Set 'GUIX_GTK2_IM_MODULE_FILE' and
'GUIX_GTK3_IM_MODULE_FILE' via profile startup files.
---
 guix/profiles.scm | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/guix/profiles.scm b/guix/profiles.scm
index 1b15257210..c998329e8a 100644
--- a/guix/profiles.scm
+++ b/guix/profiles.scm
@@ -1151,7 +1151,10 @@ for both major versions of GTK+."
                                             (map (cut string-append <> prefix "/immodules")
                                                  '#$(manifest-inputs manifest)))))
                      (modules (append-map (cut find-files <> "\\.so$")
-                                          moddirs)))
+                                          moddirs))
+                     (im-env  (string-append "GUIX_GTK" #$major "_IM_MODULE_FILE"))
+                     (envfile (string-append #$output "/etc/profile.d/gtk"
+                                             #$major "-im-modules.sh")))
 
                 ;; Generate a new immodules cache file.
                 (mkdir-p (string-append #$output prefix))
@@ -1167,7 +1170,12 @@ for both major versions of GTK+."
                             (write-char (read-char pipe) out))))
                       #t)
                     (lambda ()
-                      (close-pipe pipe)))))))))
+                      (close-pipe pipe)))
+                  ;; Set environment variable for GTK+ input method modules.
+                  (mkdir-p (dirname envfile))
+                  (with-output-to-file envfile
+                    (lambda ()
+                      (simple-format #t "export ~a=~a\n" im-env outfile)))))))))
 
     ;; Don't run the hook when there's nothing to do.
     (let* ((pkg-gtk+ (module-ref        ; lazy reference
-- 
2.29.2