Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions src/nix/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ fi
chmod +x,o+r ${FEATURE_DIR} ${FEATURE_DIR}/post-install-steps.sh
if [ "${MULTIUSER}" = "true" ]; then
/usr/local/share/nix-entrypoint.sh
su ${USERNAME} -c "
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
${FEATURE_DIR}/post-install-steps.sh
"
. /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh
NIX_FEATURE_INSTALL_PROFILE=/nix/var/nix/profiles/default ${FEATURE_DIR}/post-install-steps.sh
else
su ${USERNAME} -c "
. \$HOME/.nix-profile/etc/profile.d/nix.sh
Expand Down
14 changes: 11 additions & 3 deletions src/nix/post-install-steps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@
set -e
echo "(*) Executing post-installation steps..."

# In multi-user mode, install into the default profile that is on PATH.
NIX_ENV_PROFILE_ARGS=()
NIX_PROFILE_INSTALL_ARGS=()
if [ -n "${NIX_FEATURE_INSTALL_PROFILE}" ]; then
NIX_ENV_PROFILE_ARGS=(-p "${NIX_FEATURE_INSTALL_PROFILE}")
NIX_PROFILE_INSTALL_ARGS=(--profile "${NIX_FEATURE_INSTALL_PROFILE}")
fi

# if not starts with "nixpkgs." add it as prefix to package name
add_nixpkgs_prefix() {
local packages=$1
Expand All @@ -20,17 +28,17 @@ if [ ! -z "${PACKAGES}" ] && [ "${PACKAGES}" != "none" ]; then
if [ "${USEATTRIBUTEPATH}" = "true" ]; then
PACKAGES=$(add_nixpkgs_prefix "$PACKAGES")
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env -iA ${PACKAGES}
nix-env "${NIX_ENV_PROFILE_ARGS[@]}" -iA ${PACKAGES}
else
echo "Installing packages \"${PACKAGES}\" in profile..."
nix-env --install ${PACKAGES}
nix-env "${NIX_ENV_PROFILE_ARGS[@]}" --install ${PACKAGES}
fi
fi

# Install Nix flake in profile if specified
if [ ! -z "${FLAKEURI}" ] && [ "${FLAKEURI}" != "none" ]; then
echo "Installing flake ${FLAKEURI} in profile..."
nix profile install "${FLAKEURI}"
nix profile install "${NIX_PROFILE_INSTALL_ARGS[@]}" "${FLAKEURI}"
fi

nix-collect-garbage --delete-old
Expand Down
1 change: 1 addition & 0 deletions test/nix/packages.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ check "nix-env" type nix-env
check "vim_installed" type vim
check "node_installed" type node
check "yarn_installed" type yarn
check "vim_in_default_profile" bash -lc "nix-env -p /nix/var/nix/profiles/default -q | grep -q '^vim'"

# Report result
# If any of the checks above exited with a non-zero exit code, the test will fail.
Expand Down
2 changes: 1 addition & 1 deletion test/nix/scenarios.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@
"remoteUser": "vscode",
"features": {
"nix": {
"packages": "nodePackages.nodejs,nixpkgs.vim,nixpkgs.yarn",
"packages": "nodejs,nixpkgs.vim,nixpkgs.yarn",
"useAttributePath": true
}
}
Expand Down
Loading