feat: add haskell-language-server 2.14.0.0#214
Conversation
Add package for the Haskell Language Server (HLS), the official LSP implementation for Haskell. Builds from source using GHC + Cabal with dynamic linking, copying the binary and all required shared libraries via ldd dependency resolution. - Source: GitHub tag 2.14.0.0 with automatic extraction - Build deps: base, cabal, ghc - Runtime deps: glibc - Network access enabled for cabal dependency index updates - Includes standalone version check test
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
⚠️ Packaging and Operational Risk: Unsafe Dynamic Library Bundling
Hi @0chroma! Thanks for adding haskell-language-server.
During a review of the aggregated unstable build, we identified a significant operational and runtime risk in packages/haskell-language-server/build.sh:
The current script uses ldd to copy all linked dynamic libraries into $OUTPUT_DIR/usr/lib:
# Copy all shared Haskell libraries the binary depends on
for lib in $(ldd "$HLS_BIN" | grep '\.so' | awk '{print $3}'); do
if [ -n "$lib" ] && [ -f "$lib" ]; then
cp "$lib" "$OUTPUT_DIR"/usr/lib/
fi
doneWhy this is a problem:
- System Library Pollution:
lddreturns system-wide libraries such aslibc.so.6,libm.so.6,libpthread.so.0, and the dynamic linker. Copying these into/usr/lib/of the package packages them along withhaskell-language-server. - Dynamic Loader Collisions & Crashes: Distributing duplicate, potentially out-of-sync or incompatible core system GLIBC libraries in application packages is highly risky. It can cause severe runtime crashes (segmentation faults), loader conflicts, or even break the base system container's loader when installed.
- Bloat: It dramatically inflates the package size unnecessarily.
Recommended Fix:
Haskell executable targets built by Cabal statically link Haskell package dependencies by default. Standard external C library dependencies (such as GLIBC) should be resolved dynamically from the base system (since glibc is already in your runtime_deps).
Therefore, you can safely remove the library-copying block entirely. Here is the recommended clean build script:
#!/bin/bash
set -euo pipefail
# The source tarball is already extracted with strip_prefix, so we're in the source root
# Build HLS for the GHC version available in the sandbox
export GHC="$(command -v ghc)"
export CABAL="$(command -v cabal)"
# Update cabal package index
cabal update
# Build HLS with the available GHC version
cabal build \
--ghc-options="-j$(nproc)" \
exe:haskell-language-server
# Install to OUTPUT_DIR
mkdir -p "$OUTPUT_DIR"/usr/bin
# Find and copy the built binary from cabal's build directory
HLS_BIN=$(cabal list-bin exe:haskell-language-server)
cp "$HLS_BIN" "$OUTPUT_DIR"/usr/bin/And in packages/haskell-language-server/build.ncl, you can simplify the outputs definition by removing the libs entry:
outputs = {
hls = { glob = "usr/bin/haskell-language-server" } | OutputBin,
},|
|
Summary
Add the Haskell Language Server (HLS) v2.14.0.0 to the package registry, enabling Haskell LSP support for editors like Neovim, VS Code, and Emacs.
Context
HLS is the official Language Server Protocol implementation for Haskell, providing features like go-to-definition, type hover, code actions, and refactoring. It was missing from the registry, blocking Haskell development workflows.
Changes
packages/haskell-language-server/build.ncl— Build spec sourcing from GitHub tag 2.14.0.0 with automatic extractionpackages/haskell-language-server/build.sh— Build script using GHC + Cabal with dynamic linkingKey Implementation Details
cabal build exe:haskell-language-server(not prebuilt binaries per guidelines)lddto discover and copy all required shared Haskell libraries at runtime, avoiding static linking issues (Haskell libs aren't PIC-compatible)needs = { dns = {}, internet = {} }for Cabal dependency index updatesmin checkchecks pass, including standalone version testUse Cases
Testing