1+ # We build the Docker image from a Dockerfile rather than from a Nix expression
2+ # This is because VSCode DevContainer / GitHub Codespace run an install script
3+ # at first launch that mostly consider your machine to be Debian-based.
14FROM ubuntu:rolling
5+ # TODO: But there is likely a better immutable way to build this image ...
6+ # https://github.com/input-output-hk/devx-aux/issues/115
27WORKDIR /workspaces
38
49ARG PLATFORM="x86_64-linux"
@@ -24,29 +29,32 @@ source $(grep -m 1 -e '-env.sh$' store-paths.txt)
2429EOF
2530
2631# This enforce those settings in DevContainer whatever "Settings Sync" user preferences ...
27- RUN mkdir -p $HOME/.vscode-server/data/Machine/ \
28- && cat <<EOF >> $HOME/.vscode-server/data/Machine/settings.json
29- { "haskell.manageHLS" : "PATH" }
30- EOF
32+ RUN bash -ic 'source $HOME/.bashrc && mkdir -p $HOME/.vscode-server/data/Machine/ && \
33+ echo -e "{\n \
34+ \" haskell.manageHLS\" : \" PATH\" ,\n \
35+ \" haskell.serverEnvironment\" : { \" PATH\" : \" $PATH\" },\n \
36+ \" haskell.serverExecutablePath\" : \" $(which haskell-language-server)\"\n \
37+ }" > $HOME/.vscode-server/data/Machine/settings.json'
3138
3239# FIXME: Consider moving this script into a Nix `writeShellApplication` trivial builder within the closure ...
3340# ... but that means I should figure it out how to pass to it $COMPILER_NIX_NAME as input?
3441RUN mkdir -p /usr/local/bin/ \
3542 && cat <<EOF >> /usr/local/bin/post-create-command
3643# !/usr/bin/env bash
3744
38- PROJECT_DIR=\$ (find /workspaces/ -mindepth 1 -maxdepth 1 -type d)
45+ PROJECT_DIR=\$ (find /workspaces/ -mindepth 1 -maxdepth 1 -type d ! -name '.*' -print -quit )
3946if [ -n "\$ PROJECT_DIR" ]; then
4047 pushd \$ PROJECT_DIR > /dev/null
41- # GitHub Codespaces should have \$GH_TOKEN already set.
42- if [ -n "\$ GH_TOKEN" ]; then
48+ # GitHub Codespaces should have \$GITHUB_TOKEN already set.
49+ if [ -n "\$ GITHUB_TOKEN" ]; then
50+ echo \$ GITHUB_TOKEN | gh auth login --with-token
4351 COMMIT_HASH=\$ (git rev-parse HEAD)
4452 echo "Attempting to download HLS cache from GitHub Artifact (cache-\$ COMMIT_HASH-$COMPILER_NIX_NAME) for faster first launch ..."
4553 gh run download -D .download -n "cache-\$ COMMIT_HASH-$COMPILER_NIX_NAME"
4654 rsync -a .download/work/cardano-base/cardano-base/dist-newstyle .
4755 rm -r .download
4856 else
49- echo "\\\$ GH_TOKEN is not set. Skipping HLS cache download."
57+ echo "\\\$ GITHUB_TOKEN is not set. Skipping HLS cache download."
5058 fi
5159 # HLS error (Couldn't load cradle for ghc libdir) if `cabal update` has never been run in project using cardano-haskell-packages ...
5260 echo "Running `cabal update` ..."
0 commit comments