Subject: bug#78363: [PATCH 3/3] environment: Make home writable.

From: Tomas Volf <[email-masked]>
Date: Sun, 18 May 2025 15:39:36 +0200

* guix/scripts/environment.scm (launch-environment/container): Add tmpfs for
home.
* tests/guix-environment-container.sh: Add test.

Change-Id: Iadd9b838f6442a8080998ed7e07414db562068bf
---
 guix/scripts/environment.scm        | 9 ++++++++-
 tests/guix-environment-container.sh | 4 ++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index bc06e97d7b..96bbc6c9fa 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -874,7 +874,14 @@ (define* (launch-environment/container #:key command bash user user-mappings
                       (writable? #f)))
                    reqs)))
             (file-systems (append %container-file-systems
-                                  (list tmpfs)
+                                  (list tmpfs        ; RW /tmp
+                                        (file-system ; RW ~
+                                          (device "none")
+                                          (mount-point
+                                           (or (and=> user user-override-home)
+                                               home))
+                                          (type "tmpfs")
+                                          (check? #f)))
                                   (if network?
                                       (filter-map optional-mapping->fs
                                                   %network-file-mappings)
diff --git a/tests/guix-environment-container.sh b/tests/guix-environment-container.sh
index d0f19c8372..e1c3655846 100644
--- a/tests/guix-environment-container.sh
+++ b/tests/guix-environment-container.sh
@@ -199,6 +199,10 @@ guix environment --bootstrap --container --ad-hoc guile-bootstrap	\
 guix environment --bootstrap --container --ad-hoc guile-bootstrap \
      -- guile -c '(mkdir "/tmp/foo")'
 
+# And so is ~.
+guix environment --bootstrap --container --ad-hoc guile-bootstrap \
+     -- guile -c '(mkdir (string-append (getenv "HOME") "/foo"))'
+
 
 # Check the exit code.
 
-- 
2.49.0