Skip to content

feat: add haskell-language-server 2.14.0.0 - #214

Merged
bryan-minimal merged 9 commits into
mainfrom
add/haskell-language-server
Jul 29, 2026
Merged

feat: add haskell-language-server 2.14.0.0#214
bryan-minimal merged 9 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

Summary by CodeRabbit

  • New Features
    • Added the Haskell Language Server package, version 2.14.0.0.
    • Includes the haskell-language-server executable and required runtime libraries.
    • Added a version verification check for the packaged language server.
    • Added packaged shared data files for Alex and Happy.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 8b797e6a-8f95-469f-a04c-4ef694ccc2d8

📥 Commits

Reviewing files that changed from the base of the PR and between defad31 and d420cf4.

📒 Files selected for processing (4)
  • packages/alex/build.ncl
  • packages/happy/build.ncl
  • packages/haskell-language-server/build.ncl
  • packages/haskell-language-server/build.sh

📝 Walkthrough

Walkthrough

Adds OutputData outputs to Alex and Happy, and introduces a pinned Haskell Language Server build specification with dependency wiring, build script, executable and library packaging, metadata, and a version check.

Changes

Haskell tooling packages

Layer / File(s) Summary
Toolchain data outputs
packages/alex/build.ncl, packages/happy/build.ncl
Alex and Happy now expose usr/share/** files through OutputData outputs.
Language Server build specification
packages/haskell-language-server/build.ncl
Defines the pinned source, dependencies, build arguments, outputs, provenance metadata, and --version test.
Build and packaging script
packages/haskell-language-server/build.sh
Builds with Cabal and the sandbox toolchain, extracts relevant failure output, and packages the executable with libHS* libraries.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: bryan-minimal

Sequence Diagram(s)

sequenceDiagram
  participant BuildSpec
  participant build.sh
  participant Cabal
  participant GHC
  participant OUTPUT_DIR
  BuildSpec->>build.sh: pass version and build inputs
  build.sh->>Cabal: update package index and build executable
  Cabal->>GHC: compile with sandbox toolchain
  build.sh->>OUTPUT_DIR: install executable and libHS* libraries
  BuildSpec->>OUTPUT_DIR: run haskell-language-server --version
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly states the main change: adding haskell-language-server version 2.14.0.0.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch add/haskell-language-server

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

@edge-delta edge-delta Bot left a comment

Copy link
Copy Markdown
Contributor

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.

0chroma and others added 2 commits July 25, 2026 00:51
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
@0chroma
0chroma force-pushed the add/haskell-language-server branch from d71a920 to f224abc Compare July 25, 2026 07:51
0chroma added 7 commits July 25, 2026 01:24
…/benchmark builds

The HLS cabal.project ships with tests:True and benchmarks:True, which makes
cabal resolve and compile test/benchmark deps for every transitive dependency
— a major cost and failure surface for a 16+ minute build. Pass
--disable-tests --disable-benchmarks to build only the executable.

Also add alex, happy, and zlib as explicit build_deps. alex and happy are in
ghc's build_deps (not runtime_deps), so they aren't injected into downstream
builds — cabal would otherwise have to download and compile them from Hackage.
zlib provides the C library needed by HLS's Haskell dependencies.
Without CABAL_DIR, cabal has no writable home for its config, package index,
and build store in the sandboxed build environment — the most likely root
cause of the 17-minute build failures. Every other Haskell package in the
repo (tamarin-prover, stack) sets this; HLS was the only one that didn't.

Also add --with-compiler for explicitness, -v1 for verbose output, and an
error-capture block (matching tamarin-prover's pattern) that extracts the
real compile/link error on failure instead of a bare "build failed" exit.
Replace --ghc-options="-j$(nproc)" (per-module GHC parallelism) with
--jobs="$(nproc)" (per-package cabal parallelism). HLS is a massive
project — running nproc GHC instances each with nproc internal module
threads exhausts memory on the build host. Cabal-level parallelism
compiles packages concurrently while keeping module compilation
sequential within each package, matching the tamarin-prover build.
The HLS binary links against libgmp, libffi, and libz (GHC runtime
dependencies), but runtime_deps only declared glibc — causing the
missing-runtime-deps and standalone-test post-build checks to fail.
Move zlib from build_deps to runtime_deps (runtime_deps are injected
into the build env, so it covers both roles), and add gmp + libffi
matching GHC's own runtime_deps.
Cabal installs alex/happy from Hackage as build-tool-depends, but the
installed binaries link against GHC's shared libraries (libHSrts etc.)
which aren't on the default library search path — so they fail to run
and cabal reports "version could not be determined" (Cabal-1008).

Two fixes:
- Add GHC's libdir to LD_LIBRARY_PATH so cabal-installed build tools
  can actually execute
- Pass --with-alex/--with-happy pointing at the pre-installed system
  versions so cabal uses those for version checks instead of its own
  broken copies
The system alex/happy were built with ghc-bootstrap 9.8.1, so their
template files live in /usr/share/x86_64-linux-ghc-9.8.1/... — wrong
GHC version. Passing --with-alex/--with-happy made cabal use those
binaries, which then failed looking for templates in the 9.8.1 data
dir. Remove the --with-* flags so cabal installs its own alex/happy
from Hackage (built with 9.10.3, correct data dir). The LD_LIBRARY_PATH
fix ensures those cabal-installed tools can actually execute.
alex and happy only captured their binary (usr/bin/alex, usr/bin/happy)
as OutputBin — the template files that ./Setup copy installs to
usr/share/x86_64-linux-ghc-<version>/... were discarded. Without the
templates, the tools fail with "openFile: does not exist" when any
downstream package uses them.

Add a data OutputData (usr/share/**) to both alex and happy so the
template files ship with the package. Then use --with-alex/--with-happy
in the HLS build to point cabal at the pre-packaged versions instead of
letting it download and build its own copies from Hackage — those
copies were the source of the "version could not be determined"
(Cabal-1008) failures.

alex/happy are standalone code generators; they don't need to match
the downstream GHC version, they just need their template files at
the hardcoded path.
@0chroma
0chroma marked this pull request as ready for review July 25, 2026 12:40

@bryan-minimal bryan-minimal left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, the build passed

@bryan-minimal
bryan-minimal added this pull request to the merge queue Jul 29, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to no response for status checks Jul 29, 2026
@bryan-minimal
bryan-minimal added this pull request to the merge queue Jul 29, 2026
Merged via the queue into main with commit 02e5f82 Jul 29, 2026
9 of 10 checks passed
@bryan-minimal
bryan-minimal deleted the add/haskell-language-server branch July 29, 2026 21:22
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.

3 participants