Use nix-haskell and provide source-repository-packages to Cabal in shell #1

Open
georgefst wants to merge 1 commits from nix-haskell into main
Owner
No description provided.
georgefst added 1 commit 2026-03-24 16:02:13 +00:00
georgefst reviewed 2026-03-24 16:19:45 +00:00
@ -6,0 +3,4 @@
nix-haskell.url = "github:reflex-frp/nix-haskell";
hls-src = { url = "github:haskell/haskell-language-server/2.13.0.0"; flake = false; };
hs-bindgen-src = { url = "github:well-typed/hs-bindgen/6ca94188abd756a1fb4dd8a4037de3fa7dca0765"; flake = false; };
libclang-src = { url = "github:well-typed/libclang/d6e482df49b88375cf3075928a78ee86c2a068d4"; flake = false; };
Author
Owner

Matching to old cabal.project for now, but we should probably just let flake.lock do the pinning. Main thing is I've forgotten how exactly to set a specific commit with nix flake update... Actually to be honest at this point we could probably just use the latest HEAD anyway.

Matching to old `cabal.project` for now, but we should probably just let `flake.lock` do the pinning. Main thing is I've forgotten how exactly to set a specific commit with `nix flake update`... Actually to be honest at this point we could probably just use the latest `HEAD` anyway.
Author
Owner

This is kind of irrelevant now that we're about to bump to HEAD anyway in order to make use of some new features.

This is kind of irrelevant now that we're about to bump to `HEAD` anyway in order to make use of some new features.
georgefst marked this conversation as resolved
@ -8,3 +9,3 @@
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs.follows = "nix-haskell/nixpkgs";
Author
Owner

The examples somehow avoid flake-utils. We should perhaps try to do the same.

The examples somehow avoid `flake-utils`. We should perhaps try to do the same.
Author
Owner

Oh, actually, they're just hardcoding x86_64-linux.

Still, maybe I should look at using plain genAttrs instead. I know this is tricky with Haskell.Nix as it requires transposing the two outermost attrset layers.

Oh, actually, they're just hardcoding `x86_64-linux`. Still, maybe I should look at using plain `genAttrs` instead. I know this is tricky with Haskell.Nix as it requires transposing the two outermost attrset layers.
@ -50,1 +32,3 @@
haskell.devShells.default
(haskell.shell.overrideAttrs (old: {
shellHook = builtins.replaceStrings [ "*wasm*|)" ] [ "*wasm*)" ] old.shellHook;
}))
Author
Owner

This should just be haskell.shell. Patched to avoid an annoying warning on entering nix develop shell:

bash: eval: line 2229: syntax error near unexpected token `)'
bash: eval: line 2229: `        *wasm*|)  ;;'

This seems like a nix-haskell bug.

This should just be `haskell.shell`. Patched to avoid an annoying warning on entering `nix develop` shell: ``` bash: eval: line 2229: syntax error near unexpected token `)' bash: eval: line 2229: ` *wasm*|) ;;' ``` This seems like a `nix-haskell` bug.
Collaborator

Fixed upstream

Fixed upstream
georgefst marked this conversation as resolved
@ -0,0 +14,4 @@
c-expr-runtime = hs-bindgen-src + "/c-expr-runtime";
hs-bindgen = hs-bindgen-src + "/hs-bindgen";
hs-bindgen-runtime = hs-bindgen-src + "/hs-bindgen-runtime";
libclang-bindings = libclang-src;
Author
Owner

I was hoping that these might just be picked up automatically from cabal.project. Haskell.nix does do this, but then Cabal in the shell insists on building the libraries again itself anyway, which to be fair doesn't happen with this approach. See issue.

Anyway, maybe it's fine. It is generally nice to have projects buildable without Nix. And retaining this property is a big part of the design goals of Haskell.nix. But it doesn't realistically matter in practice for this project.

I was hoping that these might just be picked up automatically from `cabal.project`. Haskell.nix does do this, but then Cabal in the shell insists on building the libraries again itself anyway, which to be fair doesn't happen with this approach. See [issue](https://github.com/input-output-hk/haskell.nix/issues/1637). Anyway, maybe it's fine. It is generally _nice_ to have projects buildable without Nix. And retaining this property is a big part of the design goals of Haskell.nix. But it doesn't realistically matter in practice for this project.
Author
Owner

And actually, having the flake inputs be the source of truth is quite convenient, as I've just realised when running nix flake update hs-bindgen-src for the first time. Cabal has no equivalent CLI.

And actually, having the flake inputs be the source of truth is quite convenient, as I've just realised when running `nix flake update hs-bindgen-src` for the first time. Cabal has no equivalent CLI.
@ -0,0 +35,4 @@
};
};
withHoogle = false;
withHaddock = true;
Author
Owner

These two don't seem to be working.

No HLS hover docs for any definitions from non-boot libs, e.g. withHsBindgen or def. And I'm pretty sure I've seen Hoogle stuff get built anyway.

Note that the HLS override does work.

These two don't seem to be working. No HLS hover docs for any definitions from non-boot libs, e.g. `withHsBindgen` or `def`. And I'm pretty sure I've seen Hoogle stuff get built anyway. Note that the HLS override _does_ work.
Author
Owner

To be fair, I don't think I tried withHaddock or equivalent with plain Haskell.nix, so my expectations may be wrong.

To be fair, I don't think I tried `withHaddock` or equivalent with plain Haskell.nix, so my expectations may be wrong.
This pull request can be merged automatically.
You are not authorized to merge this pull request.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin nix-haskell:nix-haskell
git checkout nix-haskell
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: georgefst/garnet#1
No description provided.