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

haskell - change devcontainer to use GHCup #1478

Merged
merged 9 commits into from
Sep 3, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
51 changes: 38 additions & 13 deletions containers/haskell/.devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,25 +1,50 @@
# Use the [Choice] comment to indicate option arguments that should appear in VS Code UX
#
# [Choice] Haskell version: 9, 8
ARG VARIANT=8
FROM haskell:${VARIANT}

# Use the [Option] comment to specify true/false arguments that should appear in VS Code UX
#
FROM debian:bullseye-slim

ENV LANG C.UTF-8

# [Option] Install zsh
ARG INSTALL_ZSH="true"
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="false"

# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies
# Install needed packages and setup non-root user.
# Use a separate RUN statement to add your own dependencies
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY library-scripts/*.sh /tmp/library-scripts/
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true"\
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
&& rm -rf /tmp/library-scripts

# common haskell + stack dependencies
RUN apt-get install -y --no-install-recommends \
dpkg-dev \
gcc \
libc6-dev \
libffi-dev \
libgmp-dev \
libnuma-dev \
libtinfo-dev \
zlib1g-dev \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/*
gusbicalho marked this conversation as resolved.
Show resolved Hide resolved

# Install latest GHCup in the non-root user home
USER $USERNAME

RUN mkdir -p "$HOME/.ghcup/bin" \
&& curl -LJ "https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup" -o "$HOME/.ghcup/bin/ghcup" \
&& chmod +x "$HOME/.ghcup/bin/ghcup"
ENV PATH="/home/$USERNAME/.cabal/bin:/home/$USERNAME/.ghcup/bin:$PATH"

# [Choice] GHC version: recommended, latest, 9.2, 9.0, 8.10, 8.8, 8.6
ARG GHC_VERSION="recommended"

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
# Use GHCup to install versions of main utilities
# If you prefer to let the Haskell extension install everything on demand,
# comment out the lines below. In that case, you may need to manually run "cabal update""."
RUN ghcup install ghc "${GHC_VERSION}" --set \
&& ghcup install cabal recommended --set \
&& ghcup install stack recommended --set \
&& ghcup install hls recommended --set \
&& cabal update
45 changes: 19 additions & 26 deletions containers/haskell/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
{
"name": "Haskell (Community)",

// Update the 'dockerfile' property if you aren't using the standard 'Dockerfile' filename.
"build": {
"dockerfile": "Dockerfile",
"args": {
// Update 'VARIANT' to pick a Haskell version: 9, 8
"VARIANT": "8"
}
"dockerfile": "Dockerfile",
"args": {
// Update 'GHC_VERSION' to pick a GHC version: recommended, latest, 9.2, 9.0, 8.10, 8.8, 8.6
"GHC_VERSION": "recommended"
}
},
// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"haskell.manageHLS": "GHCup"
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"haskell.haskell"
]
}
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"haskell.haskell"
]
}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "uname -a",


// Comment out to connect as root instead. To add a non-root user, see: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
8 changes: 5 additions & 3 deletions containers/haskell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ _This definition will hopefully get you going quickly with Haskell running as a

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

## Using this definition

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.
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.

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.

```json
"build": {
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "9"
"GHC_VERSION": "9.2"
}
}
```
Expand Down