Skip to content

feat: add haskell-language-server 2.14.0.0#214

Draft
0chroma wants to merge 2 commits into
mainfrom
add/haskell-language-server
Draft

feat: add haskell-language-server 2.14.0.0#214
0chroma wants to merge 2 commits into
mainfrom
add/haskell-language-server

Conversation

@0chroma

@0chroma 0chroma commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

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

  • Added packages/haskell-language-server/build.ncl — Build spec sourcing from GitHub tag 2.14.0.0 with automatic extraction
  • Added packages/haskell-language-server/build.sh — Build script using GHC + Cabal with dynamic linking

Key Implementation Details

  • Builds from source using cabal build exe:haskell-language-server (not prebuilt binaries per guidelines)
  • Uses ldd to discover and copy all required shared Haskell libraries at runtime, avoiding static linking issues (Haskell libs aren't PIC-compatible)
  • Network access enabled via needs = { dns = {}, internet = {} } for Cabal dependency index updates
  • All 14 min check checks pass, including standalone version test

Use Cases

  • Haskell development with LSP-enabled editors
  • Type checking and refactoring for Haskell projects
  • Integration with cabal and Stack projects

Testing

# Validate the package spec
min check --packages haskell-language-server

# Build the package
min patched-build haskell-language-server

# Verify the binary works
min add haskell-language-server
haskell-language-server --version

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
@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: a5b4f8b7-e954-40f1-b83e-83dc95e2fdf9

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add/haskell-language-server

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@edge-delta edge-delta Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ 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
done

Why this is a problem:

  1. System Library Pollution: ldd returns system-wide libraries such as libc.so.6, libm.so.6, libpthread.so.0, and the dynamic linker. Copying these into /usr/lib/ of the package packages them along with haskell-language-server.
  2. 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.
  3. 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,
  },

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants