Skip to content

Commit

Permalink
Merge pull request #1297 from AmpersandTarski/devcontainer-fix
Browse files Browse the repository at this point in the history
Devcontainer done right
  • Loading branch information
stefjoosten authored Jun 12, 2022
2 parents 6b132da + a3484db commit 410074d
Show file tree
Hide file tree
Showing 8 changed files with 230 additions and 75 deletions.
138 changes: 94 additions & 44 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,95 @@
FROM haskell:8.10.7

# 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.
FROM debian:bullseye as base
# This .devcontainer stuff is shamelessly copied from github.com/vzarytovskii/haskell-dev-env
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID

# Create the user
RUN groupadd --gid $USER_GID $USERNAME \
&& useradd --uid $USER_UID --gid $USER_GID -m $USERNAME \
#
# [Optional] Add sudo support. Omit if you don't need to install software after connecting.
&& apt-get update \
&& apt-get install -y sudo \
&& echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME \
&& chmod 0440 /etc/sudoers.d/$USERNAME

# ********************************************************
# * Anything else you want to do like clean up goes here *
# ********************************************************
# 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 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

# RUN sudo apt-get install haskell-platform

# RUN curl -sSL https://get.haskellstack.org/ | sh

RUN stack install ormolu-0.1.4.1

USER $USERNAME
ARG GHC_VERSION=8.10.7
ARG STACK_VERSION=2.7.5
ARG STACK_RESOLVER=lts-18.28
ARG CABAL_VERSION=3.6.2.0
ARG HLS_VERSION=1.7.0.0
ARG LLVM_VERSION=12

ENV USERNAME=${USERNAME} \
USER_UID=2001 \
USER_GID=2001 \
DEBIAN_FRONTEND=noninteractive \
GHC_VERSION=${GHC_VERSION} \
STACK_RESOLVER=${STACK_RESOLVER} \
STACK_VERSION=${STACK_VERSION} \
CABAL_VERSION=${CABAL_VERSION} \
HLS_VERSION=${HLS_VERSION} \
LLVM_VERSION=${LLVM_VERSION}

RUN apt-get update
RUN apt-get install -y --no-install-recommends apt-utils bash build-essential ca-certificates curl gcc git gnupg libffi-dev libffi7 libgmp-dev libgmp-dev libgmp10 libicu-dev libncurses-dev libncurses5 libnuma1 libnuma-dev libtinfo5 lsb-release make procps software-properties-common sudo wget xz-utils z3 zlib1g-dev

RUN wget -O /tmp/llvm.sh https://apt.llvm.org/llvm.sh && chmod +x /tmp/llvm.sh && /tmp/llvm.sh ${LLVM_VERSION} && rm /tmp/llvm.sh

RUN groupadd --gid $USER_GID $USERNAME && \
useradd -ms /bin/bash -K MAIL_DIR=/dev/null --uid $USER_UID --gid $USER_GID -m $USERNAME && \
echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME

USER ${USER_UID}:${USER_GID}
WORKDIR /home/${USERNAME}
ENV PATH="/home/${USERNAME}/.local/bin:/home/${USERNAME}/.cabal/bin:/home/${USERNAME}/.ghcup/bin:$PATH"

RUN echo "export PATH=$PATH" >> /home/$USERNAME/.profile

ENV BOOTSTRAP_HASKELL_NONINTERACTIVE=yes \
BOOTSTRAP_HASKELL_NO_UPGRADE=yes

FROM base as tooling

RUN curl --proto '=https' --tlsv1.2 -sSf https://get-ghcup.haskell.org | sh

# Set the GHC version.
RUN ghcup install ghc ${GHC_VERSION} && ghcup set ghc ${GHC_VERSION}

# Install cabal-iinstall
RUN ghcup install cabal ${CABAL_VERSION} && ghcup set cabal ${CABAL_VERSION}

# Update Cabal.
RUN cabal update && cabal new-install cabal-install

# Configure cabal
RUN cabal user-config update -f && \
sed -i 's/-- ghc-options:/ghc-options: -haddock/g' ~/.cabal/config

# Install stack
RUN ghcup install stack ${STACK_VERSION} && ghcup set stack ${STACK_VERSION}

# Set system-ghc, install-ghc and resolver for stack.
RUN ((stack ghc -- --version 2>/dev/null) || true) && \
# Set global defaults for stack.
stack config --system-ghc set system-ghc true --global && \
stack config --system-ghc set install-ghc false --global && \
stack config --system-ghc set resolver $STACK_RESOLVER

# Set global custom defaults for stack.
RUN printf "ghc-options:\n \"\$everything\": -haddock\n" >> /home/${USERNAME}/.stack/config.yaml

# Install hls
RUN ghcup install hls ${HLS_VERSION} && ghcup set hls ${HLS_VERSION}

FROM tooling as packages

# Install global packages.
# Versions are pinned, since we don't want to accidentally break anything (by always installing latest).
RUN cabal install --haddock-hoogle -v \
haskell-dap-0.0.15.0 \
ghci-dap-0.0.17.0 \
haskell-debug-adapter-0.0.35.0 \
hlint-3.2.7 \
apply-refact-0.9.3.0 \
retrie-1.1.0.0 \
stylish-haskell-0.13.0.0 \
hoogle-5.0.18.3 \
ormolu-0.1.3.1 \
liquidhaskell-0.8.10.2

# Generate hoogle db
RUN hoogle generate && stack hoogle

ENV DEBIAN_FRONTEND=dialog

ENTRYPOINT ["/bin/bash"]
123 changes: 98 additions & 25 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,102 @@
{
"name": "HaskellStackDev:8.10.7",
"dockerFile": "Dockerfile",
"name": "DevContainer for Haskell (GHC, Stack, Cabal, HIE, LSP, DAP, etc.)",
"remoteUser": "vscode",
"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.
"build": {
"args": {
"USERNAME": "vscode",
"GHC_VERSION": "8.10.7",
"STACK_VERSION": "2.7.5",
"STACK_RESOLVER": "lts-18.28",
"CABAL_VERSION": "3.6.2.0",
"HLS_VERSION": "1.7.0.0",
"LLVM_VERSION": "12"
},
"context": "..",
"dockerfile": "Dockerfile"
},
"extensions": [
"haskell.haskell",
"phoityne.phoityne-vscode",
"eriksik2.vscode-ghci",
"jcanero.hoogle-vscode",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"me-dutour-mathieu.vscode-github-actions",
"redhat.vscode-yaml",
"ampersandtarski.language-ampersand",
"mhutchie.git-graph",
"editorconfig.editorconfig",
// Because of bug (see https://github.com/Microsoft/vscode/issues/45997):
"bdsoftware.format-on-auto-save"
],
"settings": {
"editor.formatonsave": true,
"files.exclude": {
"**/*.olean": true,
"**/.DS_Store": true,
"**/.git": true,
"**/.hg": true,
"**/.svn": true,
"**/CVS": true
},
"haskell.checkProject": true,
"haskell.formattingProvider": "ormolu",
"haskell.indentationRules.enabled": true,
"haskell.liquidOn": true,
"haskell.manageHLS": "GHCup",
"haskell.maxCompletions": 40,
"haskell.openDocumentationInHackage": false,
"haskell.openSourceInHackage": false,
"haskell.plugin.alternateNumberFormat.globalOn": true,
"haskell.plugin.callHierarchy.globalOn": true,
"haskell.plugin.changeTypeSignature.globalOn": true,
"haskell.plugin.class.globalOn": true,
"haskell.plugin.eval.config.diff": true,
"haskell.plugin.eval.config.exception": true,
"haskell.plugin.eval.globalOn": true,
"haskell.plugin.ghcide-code-actions-bindings.globalOn": true,
"haskell.plugin.ghcide-code-actions-fill-holes.globalOn": true,
"haskell.plugin.ghcide-code-actions-imports-exports.globalOn": true,
"haskell.plugin.ghcide-code-actions-type-signatures.globalOn": true,
"haskell.plugin.ghcide-completions.config.autoExtendOn": true,
"haskell.plugin.ghcide-completions.config.snippetsOn": true,
"haskell.plugin.ghcide-completions.globalOn": true,
"haskell.plugin.ghcide-hover-and-symbols.hoverOn": true,
"haskell.plugin.ghcide-hover-and-symbols.symbolsOn": true,
"haskell.plugin.ghcide-type-lenses.config.mode": "always",
"haskell.plugin.ghcide-type-lenses.globalOn": true,
"haskell.plugin.haddockComments.globalOn": true,
"haskell.plugin.hlint.codeActionsOn": true,
"haskell.plugin.hlint.config.flags": [],
"haskell.plugin.hlint.diagnosticsOn": true,
"haskell.plugin.importLens.codeActionsOn": true,
"haskell.plugin.importLens.codeLensOn": true,
"haskell.plugin.moduleName.globalOn": true,
"haskell.plugin.pragmas.codeActionsOn": true,
"haskell.plugin.pragmas.completionOn": true,
"haskell.plugin.qualifyImportedNames.globalOn": true,
"haskell.plugin.refineImports.codeActionsOn": true,
"haskell.plugin.refineImports.codeLensOn": true,
"haskell.plugin.refineImports.globalOn": true,
"haskell.plugin.rename.config.crossModule": true,
"haskell.plugin.rename.globalOn": true,
"haskell.plugin.retrie.globalOn": true,
"haskell.plugin.splice.globalOn": true,
"haskell.plugin.tactic.config.max_use_ctor_actions": 5,
"haskell.plugin.tactics.codeActionsOn": true,
"haskell.plugin.tactics.codeLensOn": true,
"haskell.plugin.tactics.config.auto_gas": 4,
"haskell.plugin.tactics.config.hole_severity": "hint",
"haskell.plugin.tactics.config.max_use_ctor_actions": 5,
"haskell.plugin.tactics.config.proofstate_styling": true,
"haskell.plugin.tactics.config.timeout_duration": 5,
"haskell.plugin.tactics.globalOn": true,
"haskell.plugin.tactics.hoverOn": true,
"haskell.trace.client": "error",
"haskell.trace.server": "off",
"haskell.upgradeGHCup": true,
"hoogle-vscode.useCabalDependencies": true,
"terminal.integrated.defaultProfile.linux": "bash",
"terminal.integrated.profiles.linux": {
"bash": {
Expand All @@ -15,9 +105,11 @@
},
"zsh": {
"path": "zsh",
"icon": "terminal-linux"
},
"fish": {
"path": "fish"
"path": "fish",
"icon": "terminal-linux"
},
"tmux": {
"path": "tmux",
Expand All @@ -28,24 +120,5 @@
"icon": "terminal-powershell"
}
}
},
// 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": [],
// 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": [
"justusadam.language-haskell",
"haskell.haskell",
"github.vscode-pull-request-github",
"eamodio.gitlens",
"me-dutour-mathieu.vscode-github-actions",
"redhat.vscode-yaml",
"ampersandtarski.language-ampersand",
"mhutchie.git-graph",
"editorconfig.editorconfig",
// Because of bug (see https://github.com/Microsoft/vscode/issues/45997):
"bdsoftware.format-on-auto-save"
]
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: 'status: needs triage'
assignees: ''
---

<!-- Thanks for contributing to Ampersand! Please pick a clear title and proceed.-->
<!-- Please note: If your issue is about RAP3, please report it over there:-->
<!-- https://github.com/AmpersandTarski/RAP/issues -->
Expand Down
23 changes: 23 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: ''
assignees: ''
---

**Is your feature request related to a problem? Please describe.**

<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**

<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**

<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**

<!-- Add any other context or screenshots about the feature request here. -->
1 change: 1 addition & 0 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased changes
* [Issue #1293](https://github.com/AmpersandTarski/Ampersand/issues/1293) Fixed a bug in expressions of the form `r;V;s`
* Improve devcontainer functionality for developers of Ampersand.

## v4.6.3 (28 April 2022)
* [Issue #1267](https://github.com/AmpersandTarski/Ampersand/issues/1267) Automatically add ReleaseNotes to release artefacts
Expand Down
2 changes: 1 addition & 1 deletion ampersand.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ extra-source-files:
testing/Travis/testcases/prototype/shouldSucceed/try8.adl
testing/Travis/testcases/prototype/shouldSucceed/try9.adl
testing/Travis/testcases/prototype/shouldSucceed/TTypeTest1.adl
testing/Travis/testcases/prototype/shouldSucceed/validate/Issue1293.adl
testing/Travis/testcases/prototype/shouldSucceed/validate/Issue1293.BROKENadl
testing/Travis/testcases/prototype/shouldSucceed/validate/Issue148.adl
testing/Travis/testcases/prototype/shouldSucceed/validate/Issue862a.adl
testing/Travis/testcases/prototype/shouldSucceed/validate/Issue865.adl
Expand Down
2 changes: 1 addition & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# For more information, see: https://github.com/commercialhaskell/stack/blob/release/doc/yaml_configuration.md

# Specifies the GHC version and set of packages available (e.g., lts-3.5, nightly-2015-09-21, ghc-7.10.2)
resolver: lts-18.18
resolver: lts-18.28 # HJO,20220605: If changed, make sure you change this in .devcontainer stuff as well.
# resolver: nightly-2018-11-24 # temporarily no LTS. Same as pandoc-crossref.
allow-newer: false
# Local packages, usually specified by relative directory name
Expand Down
8 changes: 4 additions & 4 deletions stack.yaml.lock
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ packages:
hackage: generic-lens-core-2.0.0.0@sha256:40b063c4a1399b3cdb19f2df1fae5a1a82f3313015c7c3e47fc23b8ef1b3e443,2913
snapshots:
- completed:
size: 586296
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/18.yaml
sha256: 63539429076b7ebbab6daa7656cfb079393bf644971156dc349d7c0453694ac2
original: lts-18.18
size: 590100
url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/18/28.yaml
sha256: 428ec8d5ce932190d3cbe266b9eb3c175cd81e984babf876b64019e2cbe4ea68
original: lts-18.28

0 comments on commit 410074d

Please sign in to comment.