mirror of
https://git.in.rschanz.org/ryan77627/guix.git
synced 2025-01-24 03:29:40 -05:00
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.
This commit is contained in:
parent
d0044216c9
commit
2acce55a00
2 changed files with 12 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
||||||
;;; GNU Guix --- Functional package management for GNU
|
;;; GNU Guix --- Functional package management for GNU
|
||||||
;;; Copyright © 2021 Andrew Tropin <andrew@trop.in>
|
;;; Copyright © 2021-2023 Andrew Tropin <andrew@trop.in>
|
||||||
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
|
;;; Copyright © 2021 Xinglu Chen <public@yoctocell.xyz>
|
||||||
;;; Copyright © 2022-2023 Ludovic Courtès <ludo@gnu.org>
|
;;; Copyright © 2022-2023 Ludovic Courtès <ludo@gnu.org>
|
||||||
;;;
|
;;;
|
||||||
|
@ -212,7 +212,9 @@ (define (environment-variable-shell-definitions variables)
|
||||||
"")
|
"")
|
||||||
((key . #t)
|
((key . #t)
|
||||||
#~(string-append "export " #$key "\n"))
|
#~(string-append "export " #$key "\n"))
|
||||||
((key . (? string? value))
|
((key . (or (? string? value)
|
||||||
|
(? file-like? value)
|
||||||
|
(? gexp? value)))
|
||||||
#~(string-append "export " #$key "="
|
#~(string-append "export " #$key "="
|
||||||
(shell-double-quote #$value)
|
(shell-double-quote #$value)
|
||||||
"\n"))
|
"\n"))
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
# GNU Guix --- Functional package management for GNU
|
# 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 © 2021 Oleg Pykhalov <go.wigust@gmail.com>
|
||||||
# Copyright © 2022 Ludovic Courtès <ludo@gnu.org>
|
# 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)
|
||||||
(gnu home services)
|
(gnu home services)
|
||||||
(gnu home services shells)
|
(gnu home services shells)
|
||||||
|
(gnu packages bash)
|
||||||
(gnu services))
|
(gnu services))
|
||||||
|
|
||||||
(home-environment
|
(home-environment
|
||||||
|
@ -82,6 +83,9 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT
|
||||||
(simple-service 'add-environment-variable
|
(simple-service 'add-environment-variable
|
||||||
home-environment-variables-service-type
|
home-environment-variables-service-type
|
||||||
`(("TODAY" . "26 messidor")
|
`(("TODAY" . "26 messidor")
|
||||||
|
("SHELL" . ,(file-append bash "/bin/bash"))
|
||||||
|
("BUILDHOSTTIME" . ,#~(strftime "%c"
|
||||||
|
(localtime (current-time))))
|
||||||
("LITERAL" . ,(literal-string "${abc}"))))
|
("LITERAL" . ,(literal-string "${abc}"))))
|
||||||
|
|
||||||
(simple-service 'home-bash-service-extension-test
|
(simple-service 'home-bash-service-extension-test
|
||||||
|
@ -149,8 +153,11 @@ EOF
|
||||||
# the content of bashrc-test-config.sh"
|
# the content of bashrc-test-config.sh"
|
||||||
grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf"
|
grep -q "the content of ~/.config/test.conf" "${HOME}/.config/test.conf"
|
||||||
grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile"
|
grep '^export PS1="\$GUIX_ENVIRONMENT λ "$' "${HOME}/.bash_profile"
|
||||||
|
|
||||||
( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" )
|
( . "${HOME}/.guix-home/setup-environment"; test "$TODAY" = "26 messidor" )
|
||||||
( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' )
|
( . "${HOME}/.guix-home/setup-environment"; test "$LITERAL" = '${abc}' )
|
||||||
|
( . "${HOME}/.guix-home/setup-environment";
|
||||||
|
echo "$SHELL" | grep "/gnu/store/.*/bin/bash" )
|
||||||
|
|
||||||
# This one should still be here.
|
# This one should still be here.
|
||||||
grep "stay around" "$HOME/.config/random-file"
|
grep "stay around" "$HOME/.config/random-file"
|
||||||
|
|
Loading…
Reference in a new issue