Skip to content
This repository was archived by the owner on Jul 23, 2021. It is now read-only.
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
78 changes: 66 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,24 +1,78 @@
FROM hmemcpy/hie:8.6.5
FROM alpine

# && nix-env -i ghc-8.6.5 \

# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser"
# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs
# will be updated to match your local UID/GID (when using the dockerFile property).
# See https://aka.ms/vscode-remote/containers/non-root-user for details.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Set to false to skip installing zsh and Oh My ZSH!
ARG INSTALL_ZSH="false"

# Location and expected SHA for common setup script - SHA generated on release
ARG INSTALL_ZSH="true"
ARG COMMON_SCRIPT_SOURCE="https://raw.githubusercontent.com/microsoft/vscode-dev-containers/master/script-library/common-alpine.sh"
ARG COMMON_SCRIPT_SHA="dev-mode"

# Configure apt and install packages
RUN apk update \
&& apk add --no-cache wget coreutils ca-certificates \
&& wget -q -O /tmp/common-setup.sh $COMMON_SCRIPT_SOURCE \
&& if [ "$COMMON_SCRIPT_SHA" != "dev-mode" ]; then echo "$COMMON_SCRIPT_SHA /tmp/common-setup.sh" | sha256sum -c - ; fi \
&& /bin/ash /tmp/common-setup.sh "$INSTALL_ZSH" "$USERNAME" "$USER_UID" "$USER_GID" \
&& rm /tmp/common-setup.sh
&& rm /tmp/common-setup.sh

RUN usermod -a -G wheel ${USERNAME}
RUN echo "%wheel ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

# Enable HTTPS support in wget and set nsswitch.conf to make resolution work within containers
RUN apk add --no-cache --update openssl \
&& echo hosts: dns files > /etc/nsswitch.conf

USER ${USER_UID}:${USER_GID}
WORKDIR /home/${USERNAME}

# Download Nix and install it into the system.
RUN wget https://nixos.org/releases/nix/nix-2.3/nix-2.3-x86_64-linux.tar.xz \
&& tar xf nix-2.3-x86_64-linux.tar.xz \
&& sudo mkdir -m 0755 /etc/nix \
&& echo -e 'sandbox = false\nkeep-derivations = false' > sudo tee /etc/nix/nix.conf \
&& sh nix-*-x86_64-linux/install \
&& sudo rm -r nix-*-x86_64-linux* \
&& sudo rm -rf /var/cache/apk/*

ARG NIXUSR=/nix/var/nix/profiles/per-user/${USERNAME}
ARG NIXPROF=${NIXUSR}/profile

ONBUILD ENV \
USER=${USERNAME} \
PATH=${NIXPROF}/bin:${NIXPROF}/sbin:/home/${USERNAME}/.local/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin \
NIX_PATH=${NIXUSR}/channels

ENV \
USER=${USERNAME} \
PATH=${NIXPROF}/bin:${NIXPROF}/sbin:/home/${USERNAME}/.local/bin:/usr/local/bin:/bin:/sbin:/usr/bin:/usr/sbin \
NIX_PATH=${NIXUSR}/channels

RUN echo ". ${NIXPROF}/etc/profile.d/nix.sh" >> ~/.profile \
&& echo ". ${NIXPROF}/etc/profile.d/nix.sh" >> ~/.zshrc \
# Make sure the channel is gcrooted, because otherwise it wouldn't be kept with keep-derivations turned off
&& nix-channel --update \
&& nix-collect-garbage --delete-old \
&& nix-store --optimise \
&& nix-store --verify --check-contents

ENTRYPOINT ["/bin/zsh"]

COPY --chown=${USERNAME}:${USERNAME} stack-config.yaml /home/${USERNAME}/.stack/config.yaml
COPY --chown=${USERNAME}:${USERNAME} stack-global-config.yaml /home/${USERNAME}/.stack/global-project/stack.yaml

RUN nix-env -i stack
RUN nix-env -i ghc-8.6.5

RUN nix-env -iA cachix -f https://cachix.org/api/v1/install \
&& cachix use all-hies \
&& nix-env -iA \
unstableFallback.selection \
--arg selector 'p: { inherit (p) ghc865; }' \
-f "https://github.com/infinisil/all-hies/tarball/85fd0be92443ca60bb649f8e7748f785fe870b7a"

RUN stack install haskell-dap ghci-dap haskell-debug-adapter

RUN nix-collect-garbage --delete-old \
&& nix-store --optimise \
&& nix-store --verify --check-contents
46 changes: 21 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,26 +1,22 @@
{
"name": "GHC 8.6.5 with HIE",
"dockerFile": "Dockerfile",
"runArgs": [],

// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/bash"
},

// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
// "appPort": [],

// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "gcc -v",

// Comment out the next line if you want to run as root instead
"remoteUser": "vscode",

// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"alanz.vscode-hie-server"
]
}
"name": "GHC+Stack",
"dockerFile": "Dockerfile",
// Use 'settings' to set *default* container specific settings.json values on container create.
// You can edit these settings after create using File > Preferences > Settings > Remote.
"settings": {
"terminal.integrated.shell.linux": "/bin/zsh",
},
// Use 'appPort' to create a container with published ports. If the port isn't working, be sure
// your server accepts connections from all interfaces (0.0.0.0 or '*'), not just localhost.
// "appPort": [],
// Uncomment the next line to run commands after the container is created.
// "postCreateCommand": "java -version",
// Comment out the next line to run as root
"remoteUser": "vscode",
// Add the IDs of extensions you want installed when the container is created in the array below.
"extensions": [
"alanz.vscode-hie-server",
"meowcolm024.has-go",
"phoityne.phoityne-vscode",
]
}
25 changes: 25 additions & 0 deletions .devcontainer/stack-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
nix:
enable: true
packages: [glpk, pcre, zlib, glibc]

# This file contains default non-project-specific settings for 'stack', used
# in all projects. For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/

# The following parameters are used by "stack new" to automatically fill fields
# in the cabal config. We recommend uncommenting them and filling them out if
# you intend to use 'stack new'.
# See https://docs.haskellstack.org/en/stable/yaml_configuration/#templates
templates:
params:
author-name: Stack User
author-email: [email protected]
github-username: stack.user
# copyright:

# The following parameter specifies stack's output styles; STYLES is a
# colon-delimited sequence of key=value, where 'key' is a style name and
# 'value' is a semicolon-delimited list of 'ANSI' SGR (Select Graphic
# Rendition) control codes (in decimal). Use "stack ls stack-colors --basic"
# to see the current sequence.
stack-colors: error=31:good=32:shell=35:dir=34:recommendation=32:target=95:module=35:package-component=9
11 changes: 11 additions & 0 deletions .devcontainer/stack-global-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This is the implicit global project's config file, which is only used when
# 'stack' is run outside of a real project. Settings here do _not_ act as
# defaults for all projects. To change stack's default settings, edit
# '/root/.stack/config.yaml' instead.
#
# For more information about stack's configuration, see
# http://docs.haskellstack.org/en/stable/yaml_configuration/
#
packages: []
resolver: lts-15.0
compiler: ghc-8.6.5