Skip to content
This repository has been archived by the owner on Jan 12, 2025. It is now read-only.

Commit

Permalink
Merge pull request #94 from jcbhmr/use-sudo-instead
Browse files Browse the repository at this point in the history
Use sudo instead
  • Loading branch information
danielbraun89 authored Nov 28, 2022
2 parents 0deb15e + 0495b96 commit 93c3255
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/haskell/devcontainer-feature.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Haskell",
"id": "haskell",
"version": "1.1.0",
"version": "2.0.0",
"description": "Installs Haskell. An advanced, purely functional programming language",
"documentationURL": "https://github.com/devcontainers-contrib/features/tree/main/src/haskell",
"options": {
Expand Down
16 changes: 9 additions & 7 deletions src/haskell/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,15 @@ fi

# The installation script is designed to be run by the non-root user
# The files need to be in the remote user's ~/ home directory
ROOT_HOME="${HOME}"
export HOME="${_REMOTE_USER_HOME}"

curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | $SHELL

export HOME="${ROOT_HOME}"
chown -R "${_REMOTE_USER}:${_REMOTE_USER}" "${_REMOTE_USER_HOME}"
# So, how do we switch users? We use 'sudo -iu <username>' to get a
# login shell of another user! We use $_REMOTE_USER as defined in
# a spec proposal (but still implemented in Codespaces): https://github.com/devcontainers/spec/blob/main/proposals/features-user-env-variables.md
# Here's some more examples using it: https://github.com/search?q=org%3Adevcontainers+_REMOTE_USER&type=code
# We also use /bin/sh as defined in the script hash-bang line instead of $SHELL.
sudo -iu "$_REMOTE_USER" <<EOF
# Install instructions from https://www.haskell.org/ghcup/#
curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh
EOF

# without restarting the shell, ghci location would not be resolved from the updated PATH
exec $SHELL
Expand Down

0 comments on commit 93c3255

Please sign in to comment.