environment: Set USER and LOGNAME in container
authorLars-Dominik Braun <ldb@leibniz-psychology.org>
Tue, 25 Aug 2020 08:52:21 +0000 (10:52 +0200)
committerLudovic Courtès <ludo@gnu.org>
Sun, 30 Aug 2020 21:51:03 +0000 (23:51 +0200)
* guix/scripts/environment.scm (launch-environment/container): Set
  username environment variables.

Signed-off-by: Ludovic Courtès <ludo@gnu.org>
guix/scripts/environment.scm

index b8979ca..1fb3505 100644 (file)
@@ -477,6 +477,7 @@ WHILE-LIST."
                             (group-entry (gid 65534) ;the overflow GID
                                          (name "overflow"))))
             (home-dir (password-entry-directory passwd))
+            (logname  (password-entry-name passwd))
             (environ  (filter (match-lambda
                                 ((variable . value)
                                  (find (cut regexp-exec <> variable)
@@ -528,6 +529,10 @@ WHILE-LIST."
                       ;; The same variables as in Nix's 'build.cc'.
                       '("TMPDIR" "TEMPDIR" "TMP" "TEMP"))
 
+            ;; Some programs expect USER and/or LOGNAME to be set.
+            (setenv "LOGNAME" logname)
+            (setenv "USER" logname)
+
             ;; Create a dummy home directory.
             (mkdir-p home-dir)
             (setenv "HOME" home-dir)