diff options
| author | Andrew Tropin <andrew@trop.in> | 2023-01-09 11:46:57 +0400 |
|---|---|---|
| committer | Andrew Tropin <andrew@trop.in> | 2023-01-09 12:03:32 +0400 |
| commit | 2acce55a00df9344d73101bb57a3961ba86105b0 (patch) | |
| tree | 1c0444128e4ad1e0e42fd5fef733d93c57516bc4 | |
| parent | d0044216c94b984bdb36a6b912fa5b34a6e6b07c (diff) | |
home: environment-variables: Return support for file-likes and gexps.
* gnu/home/services.scm (environment-variable-shell-definitions): Add support
for file-likes and gexps.
* tests/guix-home.sh: Add SHELL environment variable and test its value. Add
BUILDHOSTTIME environment variable.
| -rw-r--r-- | gnu/home/services.scm | 6 | ||||
| -rw-r--r-- | tests/guix-home.sh | 9 |
2 files changed, 12 insertions, 3 deletions
diff --git a/gnu/home/services.scm b/gnu/home/services.scm index b003c3006b3..c442da374c7 100644 --- a/gnu/home/services.scm +++ b/gnu/home/services.scm | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | ;;; GNU Guix --- Functional package management for GNU | 1 | ;;; GNU Guix --- Functional package management for GNU |
| 2 | ;;; Copyright © 2021 Andrew Tropin <andrew@trop.in> | 2 | ;;; Copyright © 2021-2023 Andrew Tropin <andrew@trop.in> |
| 3 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> | 3 | ;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz> |
| 4 | ;;; Copyright © 2022-2023 Ludovic Courtès <ludo@gnu.org> | 4 | ;;; Copyright © 2022-2023 Ludovic Courtès <ludo@gnu.org> |
| 5 | ;;; | 5 | ;;; |
| @@ -212,7 +212,9 @@ ensures variable values are properly quoted." | |||
| 212 | "") | 212 | "") |
| 213 | ((key . #t) | 213 | ((key . #t) |
| 214 | #~(string-append "export " #$key "\n")) | 214 | #~(string-append "export " #$key "\n")) |
| 215 | ((key . (? string? value)) | 215 | ((key . (or (? string? value) |
| 216 | (? file-like? value) | ||
| 217 | (? gexp? value))) | ||
| 216 | #~(string-append "export " #$key "=" | 218 | #~(string-append "export " #$key "=" |
| 217 | (shell-double-quote #$value) | 219 | (shell-double-quote #$value) |
| 218 | "\n")) | 220 | "\n")) |
diff --git a/tests/guix-home.sh b/tests/guix-home.sh index 423ebf6f33c..83ca6e72c87 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | # GNU Guix --- Functional package management for GNU | 1 | # GNU Guix --- Functional package management for GNU |
| 2 | # Copyright © 2021 Andrew Tropin <andrew@trop.in> | 2 | # Copyright © 2021-2023 Andrew Tropin <andrew@trop.in> |
| 3 | # Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> | 3 | # Copyright © 2021 Oleg Pykhalov <go.wigust@gmail.com> |
| 4 | # Copyright © 2022 Ludovic Courtès <ludo@gnu.org> | 4 | # Copyright © 2022 Ludovic Courtès <ludo@gnu.org> |
| 5 | # | 5 | # |
| @@ -62,6 +62,7 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT | |||
| 62 | (gnu home) | 62 | (gnu home) |
| 63 | (gnu home services) | 63 | (gnu home services) |
| 64 | (gnu home services shells) | 64 | (gnu home services shells) |
| 65 | (gnu packages bash) | ||
| 65 | (gnu services)) | 66 | (gnu services)) |
| 66 | 67 | ||
| 67 | (home-environment | 68 | (home-environment |
| @@ -82,6 +83,9 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT | |||
| 82 | (simple-service 'add-environment-variable | 83 | (simple-service 'add-environment-variable |
| 83 | home-environment-variables-service-type | 84 | home-environment-variables-service-type |
| 84 | `(("TODAY" . "26 messidor") | 85 | `(("TODAY" . "26 messidor") |
| 86 | ("SHELL" . ,(file-append bash "/bin/bash")) | ||
| 87 | ("BUILDHOSTTIME" . ,#~(strftime "%c" | ||
| 88 | (localtime (current-time)))) | ||
| 85 | ("LITERAL" . ,(literal-string "${abc}")))) | 89 | ("LITERAL" . ,(literal-string "${abc}")))) |
| 86 | 90 | ||
| 87 | (simple-service 'home-bash-service-extension-test | 91 | (simple-service 'home-bash-service-extension-test |
| @@ -149,8 +153,11 @@ EOF | |||
| 149 | # the content of bashrc-test-config.sh" | 153 | # the content of bashrc-test-config.sh" |
| 150 | grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf" | 154 | grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf" |
| 151 | grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile" | 155 | grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile" |
| 156 | |||
| 152 | ( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" ) | 157 | ( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" ) |
| 153 | ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' ) | 158 | ( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' ) |
| 159 | ( . "${HOME}/.guix-home/setup-environment"; | ||
| 160 | echo "$SHELL" | grep "/gnu/store/.*/bin/bash" ) | ||
| 154 | 161 | ||
| 155 | # This one should still be here. | 162 | # This one should still be here. |
| 156 | grep "stay around" "$HOME/.config/random-file" | 163 | grep "stay around" "$HOME/.config/random-file" |
