Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions packages/haskell-language-server/build.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
let { Attrs, BuildSpec, Local, Needs, OutputBin, OutputLib, Source, Test, .. } = import "minimal.ncl" in

let base = import "../base/build.ncl" in
let cabal = import "../cabal/build.ncl" in
let ghc = import "../ghc/build.ncl" in
let glibc = import "../glibc/build.ncl" in

let version = "2.14.0.0" in

{
name = "haskell-language-server",

build_deps = [
{ file = "build.sh" } | Local,
{
url = "https://github.com/haskell/haskell-language-server/archive/refs/tags/%{version}.tar.gz",
sha256 = "02fdd2ea8048cddce0872f78fcc4ba15558f751333c97d24b9abadac8ee27dcb",
extract = true,
strip_prefix = "haskell-language-server-%{version}",
} | Source,
base,
ghc,
cabal,
],

runtime_deps = [glibc],

needs =
{
dns = {},
internet = {},
} | Needs,

cmd = "./build.sh",

build_args = {
include version,
},

outputs = {
hls = { glob = "usr/bin/haskell-language-server" } | OutputBin,
libs = { glob = "usr/lib/*.so*" } | OutputLib,
},

attrs =
{
upstream_version = version,
source_provenance = {
category = 'GithubRepo,
owner = "haskell",
repo = "haskell-language-server",
},
build_cost_multiple = 4,
} | Attrs,

tests = {
version_check =
{
class = 'Standalone,
test_deps = [],
cmds = [["haskell-language-server", "--version"]],
} | Test,
},
} | BuildSpec
31 changes: 31 additions & 0 deletions packages/haskell-language-server/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/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
mkdir -p "$OUTPUT_DIR"/usr/lib

# 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/

# 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