-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a feature for Haskell (GHC) #470
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ jobs: | |
"git-lfs", | ||
"github-cli", | ||
"go", | ||
"haskell", | ||
"hugo", | ||
"java", | ||
"kubectl-helm-minikube", | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
|
||
|
||
## OS Support | ||
|
||
This Feature should work on recent versions of Debian/Ubuntu-based distributions with the `apt` package manager installed. | ||
|
||
`bash` is required to execute the `install.sh` script. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
{ | ||
"id": "haskell", | ||
"version": "1.0.0", | ||
"name": "Glasgow Haskell Compiler", | ||
"documentationURL": "https://github.com/devcontainers/features/tree/main/src/haskell", | ||
"description": "Installs the Glasgow Haskell Compiler", | ||
"options": { | ||
"version": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"recommended", | ||
"9.4.4", | ||
"9.2.7" | ||
], | ||
"default": "recommended", | ||
"description": "Select or enter a GHC Version to install" | ||
}, | ||
"cabalVersion": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"recommended", | ||
"3.6.2.0" | ||
], | ||
"default": "recommended", | ||
"description": "Select or enter a Cabal Version to install" | ||
}, | ||
"hlsVersion": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"recommended", | ||
"1.9.0.0" | ||
], | ||
"default": "recommended", | ||
"description": "Select or enter a Haskell Language Server Version to install" | ||
}, | ||
"stackVersion": { | ||
"type": "string", | ||
"proposals": [ | ||
"latest", | ||
"recommended", | ||
"2.9.3" | ||
], | ||
"default": "recommended", | ||
"description": "Select or enter a Stack Version to install" | ||
} | ||
}, | ||
"installsAfter": [ | ||
"ghcr.io/devcontainers/features/common-utils" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,42 @@ | ||||
#!/usr/bin/env bash | ||||
set -e | ||||
set -o xtrace | ||||
|
||||
GHCUP_VERSION="0.1.19.2" | ||||
samruddhikhandale marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, please use the bootstrap script to always get the latest ghcup. Pinning ghcup version is not recommended. |
||||
|
||||
architecture="$(arch)" | ||||
GHCUP_BIN="${architecture}-linux-ghcup-${GHCUP_VERSION}" | ||||
|
||||
BOOTSTRAP_HASKELL_GHC_VERSION="${VERSION:-"recommended "}" | ||||
|
||||
# Maybe install curl, gcc, make | ||||
for x in curl gcc make; do | ||||
which $x > /dev/null || (apt update && apt install $x -y -qq) | ||||
done | ||||
Comment on lines
+12
to
+15
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to use a generic snippet to check other Features to do this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't quite follow this comment, can you clarify? Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe @eitsupi is referring to using I think it would be nice to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hrm, I'm not sure that those scripts do exactly what I want to do here. For example, they won't work correctly on a non-debian image where Additionally, copying functions from one install.sh to another doesn't seem to be a great practice, is there a way to share common script snippets between features? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Note that this repository is focused on debian-based containers at this time. Most Features will only work with debian-based images. Line 32 in 1449f41
|
||||
|
||||
GHCUP_DIR=${_REMOTE_USER_HOME}/.ghcup/bin | ||||
|
||||
mkdir -p $GHCUP_DIR | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if we should add a new user group Ref: https://github.com/devcontainers/features/blob/main/src/ruby/install.sh#LL206-L209C7 & There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where
We have https://github.com/devcontainers/features/blob/main/src/ruby/install.sh#L39-L59 to automatically figure out the USERNAME There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure it's necessary, this will land in the home directory, but it doesn't really need a different username imho. |
||||
echo https://downloads.haskell.org/~ghcup/${GHCUP_VERSION}/${architecture}-linux-ghcup-${GHCUP_VERSION} --output ${GHCUP_BIN} | ||||
curl https://downloads.haskell.org/~ghcup/${GHCUP_VERSION}/${architecture}-linux-ghcup-${GHCUP_VERSION} --output ${GHCUP_BIN} | ||||
# echo "25b7fc417c1a811dd7ff439b67ea647a59cf5b8d71b274f97e917d50b2150d5b ${GHCUP_BIN}" | sha256sum --check --status | ||||
|
||||
mv ${GHCUP_BIN} $GHCUP_DIR/ghcup | ||||
chmod a+x $GHCUP_DIR/ghcup | ||||
|
||||
export GHCUP_INSTALL_BASE_PREFIX=${_REMOTE_USER_HOME} | ||||
|
||||
${GHCUP_DIR}/ghcup install ghc $BOOTSTRAP_HASKELL_GHC_VERSION | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I suggest to not do all this manually, but use the bootstrap script, which allows fine grained control via env vars. E.g. curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | BOOTSTRAP_HASKELL_NONINTERACTIVE=1 BOOTSTRAP_HASKELL_CABAL_VERSION=$CABALVERSION BOOTSTRAP_HASKELL_INSTALL_HLS=1 BOOTSTRAP_HASKELL_ADJUST_BASHRC=1 sh This will also try do adjust shell config to add Right now the bootstrap script assumes you want latest of stack and HLS, but I can add environment variables to control that as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh and the bootstrap script also creates a |
||||
${GHCUP_DIR}/ghcup install cabal $CABALVERSION | ||||
${GHCUP_DIR}/ghcup install hls $HLSVERSION | ||||
${GHCUP_DIR}/ghcup install stack $STACKVERSION | ||||
|
||||
${GHCUP_DIR}/ghcup set ghc $BOOTSTRAP_HASKELL_GHC_VERSION | ||||
${GHCUP_DIR}/ghcup set cabal $CABALVERSION | ||||
${GHCUP_DIR}/ghcup set hls $HLSVERSION | ||||
${GHCUP_DIR}/ghcup set stack $STACKVERSION | ||||
brendandburns marked this conversation as resolved.
Show resolved
Hide resolved
|
||||
|
||||
# Clean up | ||||
rm -rf /var/lib/apt/lists/* | ||||
|
||||
echo "Done!" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
check "version" ~/.ghcup/bin/ghc --version | grep 9.2.6 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So is |
||
# Report result | ||
reportResults |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
EXPECTED_VERSION=$(~/.ghcup/bin/ghcup list | grep "ghc " | grep recommended | awk '{print $3}') | ||
samruddhikhandale marked this conversation as resolved.
Show resolved
Hide resolved
|
||
echo ${EXPECTED_VERSION} | ||
check "version" ~/.ghcup/bin/ghc --version | grep "${EXPECTED_VERSION}" | ||
|
||
# Report result | ||
reportResults |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
check "version" ~/.ghcup/bin/ghc --version | grep 9.2.6 | ||
|
||
# Report result | ||
reportResults |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
{ | ||
"custom_version": { | ||
"image": "ubuntu:focal", | ||
"features": { | ||
"haskell": { | ||
"version": "9.2.6" | ||
} | ||
} | ||
}, | ||
"default_version": { | ||
"image": "ubuntu:jammy", | ||
"features": { | ||
"haskell": {} | ||
} | ||
}, | ||
"mcr_version": { | ||
"image": "mcr.microsoft.com/devcontainers/base:ubuntu", | ||
"features": { | ||
"haskell": { | ||
"version": "9.2.6" | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
set -e | ||
|
||
# Optional: Import test library | ||
source dev-container-features-test-lib | ||
|
||
# Definition specific tests | ||
check "version" ~/.ghcup/bin/ghcup list | ||
|
||
# Report result | ||
reportResults |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not too familiar with how features work. My feeling is that this list can become outdated quickly. For HLS, it already is. Would it not be enough to choose between recommended and latest? Can the user enter manual strings regardless?