diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 8c215c5..471f7e6 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -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 \ No newline at end of file + && 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 diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3f8575e..3ad4ff8 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -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" - ] -} \ No newline at end of file + "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", + ] +} diff --git a/.devcontainer/stack-config.yaml b/.devcontainer/stack-config.yaml new file mode 100644 index 0000000..2ce4405 --- /dev/null +++ b/.devcontainer/stack-config.yaml @@ -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: stack.user@gmail.com + 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 diff --git a/.devcontainer/stack-global-config.yaml b/.devcontainer/stack-global-config.yaml new file mode 100644 index 0000000..e6fbeac --- /dev/null +++ b/.devcontainer/stack-global-config.yaml @@ -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