Skip to content

Commit ba85e37

Browse files
committed
add test and fix problem
1 parent 6d209bc commit ba85e37

File tree

3 files changed

+49
-3
lines changed

3 files changed

+49
-3
lines changed

src/nix/post-install-steps.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ if [ ! -z "${PACKAGES}" ] && [ "${PACKAGES}" != "none" ]; then
2020
if [ "${USEATTRPATH}" = "true" ]; then
2121
PACKAGES=$(add_nixpkgs_prefix "$PACKAGES")
2222
echo "Installing packages \"${PACKAGES}\" in profile..."
23-
nix-env -iA "${PACKAGES}"
23+
nix-env -iA ${PACKAGES}
2424
else
2525
echo "Installing packages \"${PACKAGES}\" in profile..."
26-
nix-env --install "${PACKAGES}"
26+
nix-env --install ${PACKAGES}
2727
fi
2828
fi
2929

test/nix/packages-use-attr-path.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Optional: Import test library bundled with the devcontainer CLI
5+
source dev-container-features-test-lib
6+
7+
uid="$(id -u)"
8+
echo "Current user UID is ${uid}."
9+
if [ "${uid}" != "1000" ]; then
10+
echo "Current user UID was adjusted."
11+
fi
12+
set +e
13+
vscode_uid="$(id -u vscode)"
14+
set -e
15+
if [ "${vscode_uid}" != "" ]; then
16+
echo "User vscode UID is ${vscode_uid}."
17+
if [ "${vscode_uid}" != "1000" ]; then
18+
echo "User vscode UID was adjusted."
19+
fi
20+
fi
21+
nix_uid="$(stat /nix -c "%u")"
22+
echo "/nix UID is ${nix_uid}."
23+
24+
cat /etc/os-release
25+
26+
# Feature-specific tests
27+
# The 'check' command comes from the dev-container-features-test-lib.
28+
check "nix-env" type nix-env
29+
check "vim_installed" type vim
30+
check "node_installed" type node
31+
check "yarn_installed" type yarn
32+
33+
# Report result
34+
# If any of the checks above exited with a non-zero exit code, the test will fail.
35+
reportResults &2>1

test/nix/scenarios.json

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,17 @@
8181
}
8282
}
8383
},
84+
"packages-use-attr-path": {
85+
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
86+
"remoteUser": "vscode",
87+
"features": {
88+
"nix": {
89+
"packages": "nodePackages.nodejs,nixpkgs.vim,nixpkgs.yarn",
90+
"useAttrPath": true
91+
}
92+
}
93+
},
94+
8495
"flake": {
8596
"image": "mcr.microsoft.com/devcontainers/base:ubuntu",
8697
"remoteUser": "vscode",
@@ -99,4 +110,4 @@
99110
}
100111
}
101112
}
102-
}
113+
}

0 commit comments

Comments
 (0)