Skip to content

Commit

Permalink
Set option 'system-ghc: true' system-wide
Browse files Browse the repository at this point in the history
- Also set option 'install-ghc: false' system-wide
- Reorganise files; Update .gitignore
- Update README.md
  • Loading branch information
benz0li committed Sep 11, 2023
1 parent 5d6c1d7 commit 3bdc51f
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 19 deletions.
12 changes: 10 additions & 2 deletions .devcontainer/.gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,21 @@
*

!/assets/
!/assets/screenshots/
!/bind-mounts/
!/conf/
!/conf/etc/
!/conf/etc/stack/
!/ghc-*/
!/scripts/
!/scripts/usr/
!/scripts/usr/local/
!/scripts/usr/local/bin/

!/assets/manageHLS.png
!/assets/screenshots/manageHLS.png
!/conf/etc/stack/config.yaml
!/ghc-*/devcontainer.json
!/scripts/*.sh
!/scripts/usr/local/bin/*.sh

!/devcontainer.json
!/GHC.Dockerfile
Expand Down
5 changes: 3 additions & 2 deletions .devcontainer/GHC.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ ARG STACK_VERSION_OVERRIDE=${STACK_VERSION:-none}

FROM ${BUILD_ON_IMAGE}:${GHC_VERSION} as files

RUN mkdir -p /files/usr/local/bin
RUN mkdir /files

COPY scripts /files/usr/local/bin
COPY conf /files
COPY scripts /files

## Ensure file modes are correct
RUN find /files -type d -exec chmod 755 {} \; \
Expand Down
44 changes: 29 additions & 15 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Dev Containers

These Dev Containers are based on the same docker images that are used to build
the amd64 and arm64 binary releases of pandoc.
the *statically linked* Linux amd64 and arm64 binary releases of pandoc.

Those multi-arch (`linux/amd64`, `linux/arm64/v8`) docker images themselves are
based on Alpine Linux and contain *unofficial* builds of GHC.
Expand All @@ -11,7 +11,8 @@ Only use the GHC available in the Dev Containers, because
1. the *official* GHC bindists for Alpine Linux (`x86_64`) are just too buggy.
2. there are currently (2023-08-28) no bindists for Alpine Linux (`AArch64`).

Therefore, always use options `--no-install-ghc --system-ghc` with stack.
Therefore, flags `--system-ghc` and `--no-install-ghc` are set system-wide in
`/etc/stack/config.yaml`.

## Usage

Expand All @@ -21,22 +22,35 @@ For use with Github Codespaces, please follow the instruction at
For local/'remote host' usage with VS Code, please follow the instructions at
[Developing inside a Container](https://code.visualstudio.com/docs/devcontainers/containers).

:information_source: Choose `Manually via PATH` when asked the following
question:
## Install pandoc

<img width="520" alt="manageHLS" src="assets/manageHLS.png">

## Installing pandoc

Addendum to [Installing pandoc &gt; Compiling from source &gt; Quick stack method](../INSTALL.md#quick-stack-method):

Use `stack install --no-install-ghc --system-ghc pandoc-cli` without first
running `stack setup` when building within the Dev Container (for use with
Stack).
### Using cabal

Addendum to [Installing pandoc &gt; Compiling from source &gt; Quick cabal method](../INSTALL.md#quick-cabal-method):

Use
`cabal build --enable-executable-static --ghc-option=-optl=-pthread pandoc-cli`
to build a *statically linked* `pandoc` executable that can run on any Linux
`cabal build --ghc-options '-static -optl-static -optl-pthread' pandoc-cli` to
build a *statically linked* `pandoc` executable that can run on any Linux
machine of the same architecture.

### Using stack

See [Installing pandoc &gt; Compiling from source &gt; Quick stack method](../INSTALL.md#quick-stack-method)

You may try
`stack build --ghc-options '-static -optl-static -optl-pthread' pandoc-cli` to
build a *statically linked* `pandoc` executable.
:information_source: This works on Alpine Linux/AArch64 but not x86_64[^1].

[^1]: Most likely due to a bug in the GCC toolchain on Linux/x86_64 that was
never fixed. See
[Bug #640734 “crtbeginT.o needs to be recompiled with -fPIC” : Bugs : gcc-4.4 package : Ubuntu](https://bugs.launchpad.net/ubuntu/+source/gcc-4.4/+bug/640734)
and
[gcc - Haskell Stack Static Binary relocation R_X86_64_32 against `TMC_END' can not be used when making a shared object - Stack Overflow](https://stackoverflow.com/questions/41419102/haskell-stack-static-binary-relocation-r-x86-64-32-against-tmc-end-can-not/41427067)
for more information.

## Haskell Language Server (HLS)

Choose `Manually via PATH` when asked the following question:

<img width="520" alt="manageHLS" src="assets/screenshots/manageHLS.png">
File renamed without changes
4 changes: 4 additions & 0 deletions .devcontainer/conf/etc/stack/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Use only the GHC available on the PATH
system-ghc: true
# Do not automatically install GHC when necessary
install-ghc: false
File renamed without changes.
File renamed without changes.

0 comments on commit 3bdc51f

Please sign in to comment.