feat: add a devshell for running incremental cabal build testgen-hs, editor LSP etc.#5
Conversation
ginnun
left a comment
There was a problem hiding this comment.
This works! Now I can benefit from HLS in VSCode.
One thing I might benefit from your comment.
embedFile + HLS incompatibility: The devshell provides HLS, but HLS runs with cwd at the repo root, causing embedFile "protocol-params-preview.json" in SynthEvalTx.hs to fail (file not found). Since the devshell's purpose is to enable editor support, this should be fixed, be documented, or a symlink (ln -s testgen-hs/protocol-params-preview.json protocol-params-preview.json) should be committed to the repo.
Maybe there is a much easier or no action way to do it. This is what I needed to do for HLS, we might want to add it to README:
Getting HLS working in VS Code for local development:
Install nix-direnv (required for use flake in .envrc):
nix profile install nixpkgs#nix-direnv
mkdir -p ~/.config/direnv
echo 'source $HOME/.nix-profile/share/nix-direnv/direnvrc' > ~/.config/direnv/direnvrc
Install VS Code extensions:
haskell.haskell (Haskell language support)
mkhl.direnv (direnv integration)
Set HLS to use PATH in VS Code settings:
{ "haskell.manageHLS": "PATH" }
Create a symlink for embedFile in SynthEvalTx.hs — HLS runs with cwd at the repo root, but embedFile "protocol-params-preview.json" expects the file relative to cwd:
ln -s testgen-hs/protocol-params-preview.json protocol-params-preview.json
(Consider committing this symlink to the repo, or adding working-dir support to hie.yaml once a newer HLS version supports it for cabal cradles.)
Allow direnv and restart HLS:
direnv allow
Then in VS Code: Ctrl+Shift+P → "Haskell: Restart Haskell LSP Server"
Note: The first HLS load takes ~10 minutes as hie-bios builds all dependencies via cabal v2-repl. Subsequent loads use the cache at ~/.cache/hie-bios/.
|
Hmmm. This is an issue in HLS: Allegedly it’s been fixed, I don’t know why our HLS doesn’t have this fix. But a good workaround suggested in the comment above is: -protocolParamsJSON = $(embedFile "protocol-params-preview.json")
+protocolParamsJSON = $(embedFile =<< makeRelativeToProject "protocol-params-preview.json") |
|
Re: One thing I changed is that there's no Nix profile install / config-file steps for |
ginnun
left a comment
There was a problem hiding this comment.
Thanks, this will be great!
Context
Right now the iteration time on this code is abysmal – after each change you build the full Nix package of
testgen-hs.I only meant that as a simple shim that only I edit back then, but it's grown since…
Let's add a proper devshell that allows one to run incremental
cabal build testgen-hs, andhaskell-language-serverfor editors.Demo
See the video: 2026-02-24-testgen-hs-devshell.mp4.