Improve devshell welcome message in GitHub Codespace (#147)

This commit is contained in:
Yvan Sraka 2024-04-11 14:04:16 +02:00 committed by GitHub
parent fec21531a5
commit 0a5cefb55c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 7 deletions

View File

@ -48,6 +48,9 @@ RUN mkdir -p /usr/local/bin/ \
PROJECT_DIR=\$(find /workspaces/ -mindepth 1 -maxdepth 1 -type d ! -name '.*' -print -quit)
if [ -n "\$PROJECT_DIR" ]; then
pushd \$PROJECT_DIR > /dev/null
# HLS error (Couldn't load cradle for ghc libdir) if `cabal update` has never been run in project using cardano-haskell-packages ...
echo "Running `cabal update` ..."
bash -ic "cabal update"
# GitHub Codespaces should have \$GITHUB_TOKEN already set.
if [ -n "\$GITHUB_TOKEN" ]; then
echo \$GITHUB_TOKEN | gh auth login --with-token
@ -59,9 +62,6 @@ if [ -n "\$PROJECT_DIR" ]; then
else
echo "\\\$GITHUB_TOKEN is not set. Skipping HLS cache download."
fi
# HLS error (Couldn't load cradle for ghc libdir) if `cabal update` has never been run in project using cardano-haskell-packages ...
echo "Running `cabal update` ..."
bash -c "cabal update"
popd > /dev/null
fi
EOF

View File

@ -22,9 +22,19 @@
'';
hint = flavor: ''
if [ "$GITHUB_ACTIONS" = "true" ]; then
echo "::notice::Hint: to reproduce this environment locally, use either:" \
"\`nix develop github:input-output-hk/devx#${flavor}\`, or" \
"\`docker run -it -v \$(pwd):/workspaces ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.${flavor}\`"
PREFIX="::notice::Hint:"
else
PREFIX="Hint:"
fi
if [ "$GITHUB_ACTIONS" = "true" ] || [ -n "$CODESPACE_TOKEN" ]; then
echo "$PREFIX to reproduce this environment locally, use either:" \
"\`nix develop github:input-output-hk/devx#${flavor}\`, or" \
"\`docker run -it -v \$(pwd):/workspaces ghcr.io/input-output-hk/devx-devcontainer:x86_64-linux.${flavor}\`"
fi
if [ -n "$CODESPACE_TOKEN" ]; then
echo "Quirks:"
echo -e "\tThe Haskell VSCode extension might ask you \"How do you want the extension to manage/discover HLS and the relevant toolchain?\""
echo -e "\tChoose \"Manually via PATH\", not \"Automatically via GHCup\""
fi
'';
}
}