gtk and wayland update
[jackhill/guix/guix.git] / tests / guix-home.sh
index a3c9795..3151f66 100644 (file)
@@ -1,5 +1,5 @@
 # GNU Guix --- Functional package management for GNU
-# Copyright © 2021 Andrew Tropin <andrew@trop.in>
+# Copyright © 2021-2023 Andrew Tropin <andrew@trop.in>
 # Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com>
 # Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
 #
@@ -62,6 +62,7 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
              (gnu home)
              (gnu home services)
              (gnu home services shells)
+             (gnu packages bash)
              (gnu services))
 
 (home-environment
@@ -79,6 +80,15 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
              (guix-defaults? #t)
              (bashrc (list (local-file "dot-bashrc")))))
 
+   (simple-service 'add-environment-variable
+                   home-environment-variables-service-type
+                   `(("TODAY" . "26 messidor")
+                     ("SHELL" . ,(file-append bash "/bin/bash"))
+                     ("BUILDHOST_TIME" . ,#~(strftime "%c"
+                                             (localtime (current-time))))
+                     ("STRING_WITH_ESCAPES" . "chars: \" /\\")
+                     ("LITERAL" . ,(literal-string "${abc}"))))
+
    (simple-service 'home-bash-service-extension-test
                    home-bash-service-type
                    (home-bash-extension
@@ -103,7 +113,10 @@ EOF
 
     if container_supported
     then
-       # Run the home in a container.
+       # Run the home in a container.  Always use bash inside container for
+        # reproducibility of the tests.
+        # TODO: Make container independent from external environment variables.
+        SHELL=bash
        guix home container home.scm -- true
        ! guix home container home.scm -- false
        test "$(guix home container home.scm -- echo '$HOME')" = "$HOME"
@@ -142,6 +155,13 @@ EOF
     grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf"
     grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile"
 
+    ( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" )
+    ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' )
+    ( . "${HOME}/.guix-home/setup-environment";
+      test "$STRING_WITH_ESCAPES" = "chars: \" /\\")
+    ( . "${HOME}/.guix-home/setup-environment";
+      echo "$SHELL" | grep "/gnu/store/.*/bin/bash" )
+
     # This one should still be here.
     grep "stay around" "$HOME/.config/random-file"