diff options
author | Chuck Lantz <clantz@microsoft.com> | 2022-11-01 20:02:02 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-01 20:02:02 +0300 |
commit | 0752a52b0c8ac76448666822938dce8f4d55bb69 (patch) | |
tree | 39abf9124899027643a68e5d33afc78f92ecedd9 /test/nix | |
parent | 748be9320c99cbf6e6a2885d3b5dcc39e7ad3b78 (diff) |
Nix feature (#228)
Diffstat (limited to 'test/nix')
-rwxr-xr-x | test/nix/flake.sh | 31 | ||||
-rwxr-xr-x | test/nix/multi-user-install.sh | 32 | ||||
-rwxr-xr-x | test/nix/os-alpine.sh | 34 | ||||
-rwxr-xr-x | test/nix/os-debian.sh | 22 | ||||
-rwxr-xr-x | test/nix/os-fedora.sh | 22 | ||||
-rwxr-xr-x | test/nix/os-rockylinux.sh | 22 | ||||
-rwxr-xr-x | test/nix/os-ubuntu.sh | 22 | ||||
-rwxr-xr-x | test/nix/packages.sh | 35 | ||||
-rw-r--r-- | test/nix/scenarios.json | 93 | ||||
-rwxr-xr-x | test/nix/single-user-install.sh | 40 | ||||
-rwxr-xr-x | test/nix/test.sh | 34 | ||||
-rwxr-xr-x | test/nix/version.sh | 38 |
12 files changed, 425 insertions, 0 deletions
diff --git a/test/nix/flake.sh b/test/nix/flake.sh new file mode 100755 index 0000000..03fb667 --- /dev/null +++ b/test/nix/flake.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix" type nix +check "hello" type hello + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/multi-user-install.sh b/test/nix/multi-user-install.sh new file mode 100755 index 0000000..08c64f1 --- /dev/null +++ b/test/nix/multi-user-install.sh @@ -0,0 +1,32 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/os-alpine.sh b/test/nix/os-alpine.sh new file mode 100755 index 0000000..88ca51f --- /dev/null +++ b/test/nix/os-alpine.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/os-debian.sh b/test/nix/os-debian.sh new file mode 100755 index 0000000..fe2b978 --- /dev/null +++ b/test/nix/os-debian.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/os-fedora.sh b/test/nix/os-fedora.sh new file mode 100755 index 0000000..fe2b978 --- /dev/null +++ b/test/nix/os-fedora.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/os-rockylinux.sh b/test/nix/os-rockylinux.sh new file mode 100755 index 0000000..fe2b978 --- /dev/null +++ b/test/nix/os-rockylinux.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/os-ubuntu.sh b/test/nix/os-ubuntu.sh new file mode 100755 index 0000000..fe2b978 --- /dev/null +++ b/test/nix/os-ubuntu.sh @@ -0,0 +1,22 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/packages.sh b/test/nix/packages.sh new file mode 100755 index 0000000..ad896e9 --- /dev/null +++ b/test/nix/packages.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "vim_installed" type vim +check "node_installed" type node +check "yarn_installed" type yarn + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/scenarios.json b/test/nix/scenarios.json new file mode 100644 index 0000000..72ad993 --- /dev/null +++ b/test/nix/scenarios.json @@ -0,0 +1,93 @@ +{ + "single-user-install": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "multiUser": false + } + } + }, + "version": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "multiUser": false, + "version": "2.10" + } + } + }, + "multi-user-install": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "multiUser": true + } + } + }, + "os-ubuntu": { + "image": "ubuntu", + "remoteUser": "root", + "features": { + "nix": { + "multiUser": true + } + } + }, + "os-debian": { + "image": "debian", + "remoteUser": "root", + "features": { + "nix": { + "multiUser": true + } + } + }, + "os-rockylinux": { + "image": "rockylinux:9", + "remoteUser": "root", + "features": { + "nix": { + "multiUser": true + } + } + }, + "os-fedora": { + "image": "fedora", + "remoteUser": "root", + "features": { + "nix": { + "multiUser": true + } + } + }, + "os-alpine": { + "image": "mcr.microsoft.com/devcontainers/base:alpine", + "remoteUser": "vscode", + "features": { + "nix": { + "multiUser": true + } + } + }, + "packages": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "packages": "nodejs,vim,yarn" + } + } + }, + "flake": { + "image": "mcr.microsoft.com/devcontainers/base:ubuntu", + "remoteUser": "vscode", + "features": { + "nix": { + "flakeUri": "github:nixos/nixpkgs/nixpkgs-unstable#hello" + } + } + } +}
\ No newline at end of file diff --git a/test/nix/single-user-install.sh b/test/nix/single-user-install.sh new file mode 100755 index 0000000..c7dba77 --- /dev/null +++ b/test/nix/single-user-install.sh @@ -0,0 +1,40 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo -e "User vscode UID was adjusted.\nWARNING: This scenario is not expected to work, so adjusting owner on Nix." + sudo chown -R vscode /nix + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." +if [ "${nix_uid}" != "${vscode_uid}" ]; then + echo -e "WARNING: User UID does not match /nix owner. This scenario is not expected to work, so adjusting owner of /nix for testing purposes." + sudo chown -R vscode /nix +fi + + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/test.sh b/test/nix/test.sh new file mode 100755 index 0000000..88ca51f --- /dev/null +++ b/test/nix/test.sh @@ -0,0 +1,34 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file diff --git a/test/nix/version.sh b/test/nix/version.sh new file mode 100755 index 0000000..91bf243 --- /dev/null +++ b/test/nix/version.sh @@ -0,0 +1,38 @@ +#!/bin/bash +set -e + +# Optional: Import test library bundled with the devcontainer CLI +source dev-container-features-test-lib + +uid="$(id -u)" +echo "Current user UID is ${uid}." +if [ "${uid}" != "1000" ]; then + echo "Current user UID was adjusted." +fi +set +e +vscode_uid="$(id -u vscode)" +set -e +if [ "${vscode_uid}" != "" ]; then + echo "User vscode UID is ${vscode_uid}." + if [ "${vscode_uid}" != "1000" ]; then + echo "User vscode UID was adjusted." + fi +fi +nix_uid="$(stat /nix -c "%u")" +echo "/nix UID is ${nix_uid}." +if [ "${nix_uid}" != "${vscode_uid}" ]; then + echo -e "WARNING: User UID does not match /nix owner. This scenario is not expected to work, so adjusting owner of /nix for testing purposes." + sudo chown -R vscode /nix +fi + +cat /etc/os-release + +# Feature-specific tests +# The 'check' command comes from the dev-container-features-test-lib. +check "nix-env" type nix-env +check "install" nix-env --install vim +check "vim_installed" type vim + +# Report result +# If any of the checks above exited with a non-zero exit code, the test will fail. +reportResults &2>1
\ No newline at end of file |