@@ -3,23 +3,54 @@ WORKDIR /workspaces
3
3
4
4
ARG PLATFORM="x86_64-linux"
5
5
ARG TARGET_PLATFORM=""
6
- ARG COMPILER_NIX_NAME="ghc961 "
7
- ARG MINIMAL="true "
8
- ARG IOG="false "
6
+ ARG COMPILER_NIX_NAME="ghc96 "
7
+ ARG MINIMAL="false "
8
+ ARG IOG="true "
9
9
10
10
RUN DEBIAN_FRONTEND=noninteractive \
11
11
&& apt-get update \
12
- && apt-get -y install curl git jq nix zstd \
12
+ && apt-get -y install curl gh git grep jq nix rsync zstd \
13
13
&& curl -L https://raw.githubusercontent.com/input-output-hk/actions/latest/devx/support/fetch-docker.sh -o fetch-docker.sh \
14
14
&& chmod +x fetch-docker.sh \
15
15
&& SUFFIX='' \
16
16
&& if [ "$MINIMAL" = "true" ]; then SUFFIX="${SUFFIX}-minimal" ; fi \
17
17
&& if [ "$IOG" = "true" ]; then SUFFIX="${SUFFIX}-iog" ; fi \
18
18
&& if [ "$IOG_FULL" = "true" ]; then SUFFIX="${SUFFIX}-iog-full" ; fi \
19
- && ./fetch-docker.sh input-output-hk/devx $PLATFORM.$COMPILER_NIX_NAME$TARGET_PLATFORM${SUFFIX}-env | zstd -d | nix-store --import | tee store-paths.txt \
20
- && apt-get -y remove curl git jq nix zstd \
21
- && apt-get -y autoremove \
22
- && apt-get -y autoclean
19
+ && ./fetch-docker.sh input-output-hk/devx $PLATFORM.$COMPILER_NIX_NAME$TARGET_PLATFORM${SUFFIX}-env | zstd -d | nix-store --import | tee store-paths.txt
23
20
24
- # `tail -n 2 X | head -n 1` seems a bit fragile way to get `ghc8107-iog-env.sh` derivation path ...
25
- RUN echo "source $(tail -n 2 store-paths.txt | head -n 1)" >> $HOME/.bashrc
21
+ RUN cat <<EOF >> $HOME/.bashrc
22
+ source $(grep -m 1 -e '-env.sh$' store-paths.txt)
23
+ EOF
24
+
25
+ # This enforce those settings in DevContainer whatever "Settings Sync" user preferences ...
26
+ RUN mkdir -p $HOME/.vscode-server/data/Machine/ \
27
+ && cat <<EOF >> $HOME/.vscode-server/data/Machine/settings.json
28
+ { "haskell.manageHLS" : "PATH" }
29
+ EOF
30
+
31
+ # FIXME: Consider moving this script into a Nix `writeShellApplication` trivial builder within the closure ...
32
+ # ... but that means I should figure it out how to pass to it $COMPILER_NIX_NAME as input?
33
+ RUN mkdir -p /usr/local/bin/ \
34
+ && cat <<EOF >> /usr/local/bin/post-create-command
35
+ # !/usr/bin/env bash
36
+
37
+ PROJECT_DIR=\$ (find /workspaces/ -mindepth 1 -maxdepth 1 -type d)
38
+ if [ -n "\$ PROJECT_DIR" ]; then
39
+ pushd \$ PROJECT_DIR > /dev/null
40
+ # GitHub Codespaces should have \$GH_TOKEN already set.
41
+ if [ -n "\$ GH_TOKEN" ]; then
42
+ COMMIT_HASH=\$ (git rev-parse HEAD)
43
+ echo "Attempting to download HLS cache from GitHub Artifact (cache-\$ COMMIT_HASH-$COMPILER_NIX_NAME) for faster first launch ..."
44
+ gh run download -D .download -n "cache-\$ COMMIT_HASH-$COMPILER_NIX_NAME"
45
+ rsync -a .download/work/cardano-base/cardano-base/dist-newstyle .
46
+ rm -r .download
47
+ else
48
+ echo "\\\$ GH_TOKEN is not set. Skipping HLS cache download."
49
+ fi
50
+ # HLS error (Couldn't load cradle for ghc libdir) if `cabal update` has never been run in project using cardano-haskell-packages ...
51
+ echo "Running `cabal update` ..."
52
+ bash -c "cabal update"
53
+ popd > /dev/null
54
+ fi
55
+ EOF
56
+ RUN chmod +x /usr/local/bin/post-create-command
0 commit comments