Skip to content

feat: add a devshell for running incremental cabal build testgen-hs, editor LSP etc.#5

Merged
michalrus merged 24 commits into
mainfrom
feat/devshell-proper
Mar 18, 2026
Merged

feat: add a devshell for running incremental cabal build testgen-hs, editor LSP etc.#5
michalrus merged 24 commits into
mainfrom
feat/devshell-proper

Conversation

@michalrus
Copy link
Copy Markdown
Member

@michalrus michalrus commented Feb 24, 2026

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, and haskell-language-server for editors.

Demo

See the video: 2026-02-24-testgen-hs-devshell.mp4.

@michalrus michalrus self-assigned this Feb 24, 2026
Copy link
Copy Markdown
Collaborator

@ginnun ginnun left a comment

Choose a reason for hiding this comment

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

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

@michalrus
Copy link
Copy Markdown
Member Author

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")

Fixed in 8049e57 – can you recheck, @ginnun?

@michalrus
Copy link
Copy Markdown
Member Author

michalrus commented Mar 18, 2026

Re: README.md – thanks for writing this up! Pushed in 9fd64cb.

One thing I changed is that there's no Nix profile install / config-file steps for nix-direnv. Those instructions tend to drift as upstream changes (different shells, home-manager vs. profile install, etc.), and I'd rather point people at the official direnv and nix-direnv docs than maintain our own copy.

@michalrus michalrus requested a review from ginnun March 18, 2026 12:07
Copy link
Copy Markdown
Collaborator

@ginnun ginnun left a comment

Choose a reason for hiding this comment

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

Thanks, this will be great!

@michalrus michalrus enabled auto-merge March 18, 2026 14:45
@michalrus michalrus merged commit e3c0d84 into main Mar 18, 2026
3 checks passed
@michalrus michalrus deleted the feat/devshell-proper branch March 18, 2026 18:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants