diff options
author | Ludovic Courtès <ludo@gnu.org> | 2022-03-13 22:44:54 +0100 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2022-03-19 18:51:09 +0100 |
commit | 094a2cfbe45c104d0da30ff9d975d052ca0c118c (patch) | |
tree | 3388b84418e7d951e43992e93b683c7e9bbc0420 /tests | |
parent | cff9fee82a06f58b10a5b3a7743295c53f7988b8 (diff) | |
download | guix-094a2cfbe45c104d0da30ff9d975d052ca0c118c.tar.gz |
guix home: Add 'container' command.
* guix/scripts/home.scm (show-help, %options): Add '--network', '--share', and '--expose'. (not-config?, user-shell, spawn-home-container): New procedures. (%default-system-profile): New variable. (perform-action): Add #:file-system-mappings, #:container-command, and #:network?; honor them. (process-action): Adjust accordingly. (guix-home)[parse-sub-command]: Add "container". [parse-args]: New procedure. Use it instead of 'parse-command-line'. * tests/guix-home.sh: Add tests. * doc/guix.texi (Declaring the Home Environment): Mention 'guix home container' as a way to test configuration. (Invoking guix home): Document it.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/guix-home.sh | 57 |
1 files changed, 43 insertions, 14 deletions
diff --git a/tests/guix-home.sh b/tests/guix-home.sh index 48dbcbd28f..0f68484ef4 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -26,6 +26,16 @@ set -e guix home --version +container_supported () +{ + if guile -c '((@ (guix scripts environment) assert-container-features))' + then + return 0 + else + return 1 + fi +} + NIX_STORE_DIR="$(guile -c '(use-modules (guix config))(display %storedir)')" localstatedir="$(guile -c '(use-modules (guix config))(display %localstatedir)')" GUIX_DAEMON_SOCKET="$localstatedir/guix/daemon-socket/socket" @@ -47,20 +57,6 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT ( cd "$test_directory" || exit 77 - HOME="$test_directory" - export HOME - - # - # Test 'guix home reconfigure'. - # - - echo "# This file will be overridden and backed up." > "$HOME/.bashrc" - mkdir "$HOME/.config" - echo "This file will be overridden too." > "$HOME/.config/test.conf" - echo "This file will stay around." > "$HOME/.config/random-file" - - echo -n "# dot-bashrc test file for guix home" > "dot-bashrc" - cat > "home.scm" <<'EOF' (use-modules (guix gexp) (gnu home) @@ -93,6 +89,8 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT "# the content of bashrc-test-config.sh")))))))) EOF + echo -n "# dot-bashrc test file for guix home" > "dot-bashrc" + # Check whether the graph commands work as expected. guix home extension-graph "home.scm" | grep 'label = "home-activation"' guix home extension-graph "home.scm" | grep 'label = "home-symlink-manager"' @@ -101,6 +99,37 @@ EOF # There are no Shepherd services so the one below must fail. ! guix home shepherd-graph "home.scm" + if container_supported + then + # Run the home in a container. + guix home container home.scm -- true + ! guix home container home.scm -- false + test "$(guix home container home.scm -- echo '$HOME')" = "$HOME" + guix home container home.scm -- cat '~/.config/test.conf' | \ + grep "the content of" + guix home container home.scm -- test -h '~/.bashrc' + test "$(guix home container home.scm -- id -u)" = 1000 + ! guix home container home.scm -- test -f '$HOME/sample/home.scm' + guix home container home.scm --expose="$PWD=$HOME/sample" -- \ + test -f '$HOME/sample/home.scm' + ! guix home container home.scm --expose="$PWD=$HOME/sample" -- \ + rm -v '$HOME/sample/home.scm' + else + echo "'guix home container' test SKIPPED" >&2 + fi + + HOME="$test_directory" + export HOME + + # + # Test 'guix home reconfigure'. + # + + echo "# This file will be overridden and backed up." > "$HOME/.bashrc" + mkdir "$HOME/.config" + echo "This file will be overridden too." > "$HOME/.config/test.conf" + echo "This file will stay around." > "$HOME/.config/random-file" + guix home reconfigure "${test_directory}/home.scm" test -d "${HOME}/.guix-home" test -h "${HOME}/.bash_profile" |