55 lines
2.1 KiB
Nix
55 lines
2.1 KiB
Nix
{ lib, stdenv, zig, src }:
|
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
|
pname = "srf-lsp";
|
|
# Kept in step with build.zig.zon, which is also what the server reports in its
|
|
# `initialize` response (see build.zig).
|
|
version = "0.0.1";
|
|
|
|
inherit src;
|
|
|
|
__structuredAttrs = true;
|
|
strictDeps = true;
|
|
|
|
# Zig resolves build.zig.zon dependencies over the network, which the build
|
|
# sandbox forbids. `fetchDeps` runs `zig build --fetch` inside a fixed-output
|
|
# derivation, so the fetch happens once against a known hash and the real build
|
|
# stays offline.
|
|
#
|
|
# This hash changes whenever build.zig.zon changes, which in practice means
|
|
# whenever the srf dependency is bumped. To update it: set `lib.fakeHash`, run
|
|
# the build, and paste the hash nix reports.
|
|
zigDeps = zig.fetchDeps {
|
|
inherit (finalAttrs) pname version src;
|
|
fetchAll = true;
|
|
hash = "sha256-0A2IlywPDkgX8+oiZ1Xd2zF0o07T4moBRngddwl1GBk=";
|
|
};
|
|
|
|
postConfigure = ''
|
|
# A writable copy rather than a symlink into the store: Zig writes cache
|
|
# metadata alongside the fetched packages while it verifies them.
|
|
cp -rLT ${finalAttrs.zigDeps} "$ZIG_GLOBAL_CACHE_DIR/p"
|
|
chmod -R u+w "$ZIG_GLOBAL_CACHE_DIR/p"
|
|
'';
|
|
|
|
nativeBuildInputs = [ zig ];
|
|
|
|
# The zig setup hook's check phase runs `zig build test`, which is the whole
|
|
# suite. Nothing in it touches the network or the filesystem outside the build
|
|
# directory, so it runs happily in the sandbox: every rebuild is a test run.
|
|
doCheck = true;
|
|
|
|
meta = {
|
|
description = "Language Server Protocol implementation for SRF (Simple Record Format)";
|
|
longDescription = ''
|
|
Diagnostics and hover for SRF documents, using the srf library's own parser
|
|
so the editor cannot disagree with the reference implementation. Reports
|
|
parse errors, length-prefix declarations that do not match the bytes
|
|
present, and keys whose type varies across records in one document.
|
|
'';
|
|
homepage = "https://git.lerch.org/lobo/srf-lsp";
|
|
license = lib.licenses.mit;
|
|
mainProgram = "srf-lsp";
|
|
platforms = lib.platforms.unix;
|
|
};
|
|
})
|