Skip to content

Commit

Permalink
add test and fix problem
Browse files Browse the repository at this point in the history
  • Loading branch information
nohzafk committed Jan 1, 2024
1 parent 6d209bc commit ba85e37
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/nix/post-install-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ if [ ! -z "${PACKAGES}" ] && [ "${PACKAGES}" != "none" ]; then
if [ "${USEATTRPATH}" = "true" ]; then
PACKAGES=$(add_nixpkgs_prefix "$PACKAGES")
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env -iA "${PACKAGES}"
nix-env -iA ${PACKAGES}
else
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env --install "${PACKAGES}"
nix-env --install ${PACKAGES}
fi
fi

Expand Down
35 changes: 35 additions & 0 deletions test/nix/packages-use-attr-path.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 12 additions & 1 deletion test/nix/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@
}
}
},
"packages-use-attr-path": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "vscode",
"features": {
"nix": {
"packages": "nodePackages.nodejs,nixpkgs.vim,nixpkgs.yarn",
"useAttrPath": true
}
}
},

"flake": {
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
"remoteUser": "vscode",
Expand All @@ -99,4 +110,4 @@
}
}
}
}
}

0 comments on commit ba85e37

Please sign in to comment.