Skip to content
This repository was archived by the owner on Nov 30, 2023. It is now read-only.

Commit 5d16fbe

Browse files
authored
haskell - change devcontainer to use GHCup (#1478)
1 parent 332298f commit 5d16fbe

File tree

3 files changed

+61
-42
lines changed

3 files changed

+61
-42
lines changed
+37-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,49 @@
1-
# Use the [Choice] comment to indicate option arguments that should appear in VS Code UX
2-
#
3-
# [Choice] Haskell version: 9, 8
4-
ARG VARIANT=8
5-
FROM haskell:${VARIANT}
1+
FROM debian:bullseye-slim
2+
3+
ENV LANG C.UTF-8
64

7-
# Use the [Option] comment to specify true/false arguments that should appear in VS Code UX
8-
#
95
# [Option] Install zsh
106
ARG INSTALL_ZSH="true"
117
# [Option] Upgrade OS packages to their latest versions
128
ARG UPGRADE_PACKAGES="false"
139

14-
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies
10+
# Install needed packages and setup non-root user.
11+
# Use a separate RUN statement to add your own dependencies
1512
ARG USERNAME=vscode
1613
ARG USER_UID=1000
1714
ARG USER_GID=$USER_UID
1815
COPY library-scripts/*.sh /tmp/library-scripts/
19-
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
16+
RUN apt-get update \
17+
&& export DEBIAN_FRONTEND=noninteractive \
2018
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true"\
21-
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
19+
&& rm -rf /tmp/library-scripts \
20+
&& apt-get install -y --no-install-recommends \
21+
dpkg-dev \
22+
gcc \
23+
libc6-dev \
24+
libffi-dev \
25+
libgmp-dev \
26+
libnuma-dev \
27+
libtinfo-dev \
28+
zlib1g-dev \
29+
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
30+
31+
# Install latest GHCup in the non-root user home
32+
USER $USERNAME
33+
34+
RUN mkdir -p "$HOME/.ghcup/bin" \
35+
&& curl -LJ "https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup" -o "$HOME/.ghcup/bin/ghcup" \
36+
&& chmod +x "$HOME/.ghcup/bin/ghcup"
37+
ENV PATH="/home/$USERNAME/.cabal/bin:/home/$USERNAME/.ghcup/bin:$PATH"
38+
39+
# [Choice] GHC version: recommended, latest, 9.2, 9.0, 8.10, 8.8, 8.6
40+
ARG GHC_VERSION="recommended"
2241

23-
# [Optional] Uncomment this section to install additional OS packages.
24-
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
25-
# && apt-get -y install --no-install-recommends <your-package-list-here>
42+
# Use GHCup to install versions of main utilities
43+
# If you prefer to let the Haskell extension install everything on demand,
44+
# comment out the lines below. In that case, you may need to manually run "cabal update""."
45+
RUN ghcup install ghc "${GHC_VERSION}" --set \
46+
&& ghcup install cabal recommended --set \
47+
&& ghcup install stack recommended --set \
48+
&& ghcup install hls recommended --set \
49+
&& cabal update
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,26 @@
11
{
22
"name": "Haskell (Community)",
3-
4-
// Update the 'dockerfile' property if you aren't using the standard 'Dockerfile' filename.
53
"build": {
6-
"dockerfile": "Dockerfile",
7-
"args": {
8-
// Update 'VARIANT' to pick a Haskell version: 9, 8
9-
"VARIANT": "8"
10-
}
4+
"dockerfile": "Dockerfile",
5+
"args": {
6+
// Update 'GHC_VERSION' to pick a GHC version: recommended, latest, 9.2, 9.0, 8.10, 8.8, 8.6
7+
"GHC_VERSION": "recommended"
8+
}
9+
},
10+
// Configure tool-specific properties.
11+
"customizations": {
12+
// Configure properties specific to VS Code.
13+
"vscode": {
14+
// Set *default* container specific settings.json values on container create.
15+
"settings": {
16+
"haskell.manageHLS": "GHCup"
17+
},
18+
// Add the IDs of extensions you want installed when the container is created.
19+
"extensions": [
20+
"haskell.haskell"
21+
]
22+
}
1123
},
12-
13-
// Configure tool-specific properties.
14-
"customizations": {
15-
// Configure properties specific to VS Code.
16-
"vscode": {
17-
// Add the IDs of extensions you want installed when the container is created.
18-
"extensions": [
19-
"haskell.haskell"
20-
]
21-
}
22-
},
23-
24-
// Use 'forwardPorts' to make a list of ports inside the container available locally.
25-
// "forwardPorts": [],
26-
27-
// Use 'postCreateCommand' to run commands after the container is created.
28-
// "postCreateCommand": "uname -a",
29-
30-
3124
// Comment out to connect as root instead. To add a non-root user, see: https://aka.ms/vscode-remote/containers/non-root.
3225
"remoteUser": "vscode"
3326
}

containers/haskell/README.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ _This definition will hopefully get you going quickly with Haskell running as a
99

1010
| Metadata | Value |
1111
|---------------------------- | -----------------------------------------------------------------------------|
12-
| *Contributors* | [Stuart Pike](https://github.com/stuartpike), [Javier Neira](https://github.com/jneira), [eitsupi](https://github.com/eitsupi) |
12+
| *Contributors* | [Stuart Pike](https://github.com/stuartpike), [Javier Neira](https://github.com/jneira), [eitsupi](https://github.com/eitsupi), [gusbicalho](https://github.com/gusbicalho) |
1313
| *Categories* | Community, Haskell |
1414
| *Definition type* | Dockerfile |
1515
| *Works in Codespaces* | Yes |
@@ -20,13 +20,15 @@ _This definition will hopefully get you going quickly with Haskell running as a
2020

2121
## Using this definition
2222

23-
While the definition itself works unmodified, you can select the version of Haskell the container uses by updating the `VARIANT` arg in the included `.devcontainer/devcontainer.json` file.
23+
This definition builds a container with the latest version of [GHCup](https://www.haskell.org/ghcup/). GHCup is then used to install the **recommended** (as defined by GHCup) version of GHC, cabal and stack.
24+
25+
You can choose a different GHC version to start with by setting the GHC_VERSION option in `.devcontainer/devcontainer.json`. Alternatively, you can use the `ghcup` command in a running container to manage GHC versions.
2426

2527
```json
2628
"build": {
2729
"dockerfile": "Dockerfile",
2830
"args": {
29-
"VARIANT": "9"
31+
"GHC_VERSION": "9.2"
3032
}
3133
}
3234
```

0 commit comments

Comments
 (0)