!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

720 Members
For discussions and questions about Haskell with Nix, cabal2nix and haskellPackages in nixpkgs | Current Docs: https://haskell4nix.readthedocs.io/ | More Nix: #community:nixos.org | More Haskell: #haskell-space:matrix.org143 Servers

Load older messages


SenderMessageTime
25 Aug 2025
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.03:01:29
@morgan.arnold:matrix.orgmra joined the room.07:25:22
@morgan.arnold:matrix.orgmra Howdy! Having some issues trying to set up a flake for development. I'm trying to use Clash to do FPGA stuff. The authors of Clash provide this starter template: https://github.com/clash-lang/clash-starters/tree/main/simple-nix, but I wanted to try to make a flake, thinking that it would be simpler to simply define a package, and then use nix develop to obtain a dev environment. I wrote this flake: https://paste.rs/guCkG.txt and just replaced all of the .nix files with this. It seems to work, but when I attempt to run the clash executable, I get a weird error: "<command line>: Could not find module ‘GHC.TypeLits.KnownNat.Solver’.". I can't figure out what causes this, and it doesn't happen when I run nix-develop in the root of the template as given, which is strange, since in both cases the build is just using runCabal2nix, rather than explicitly including this GHC plugin as a build input explicitly. 07:29:35
@maralorn:maralorn.demaralorn @morgan.arnold:matrix.org One theory would be, that your flake is picking a different nixpkgs version. The template seems to be pinned to a known good version. 07:51:34
@morgan.arnold:matrix.orgmra oh, that's bizarre. somehow didn't notice all of the weirdness in the nix/ directory... is there a straightforward way of copying over the nix/ directory and then using that as the nixpkgs input for my flake? that seems like the simplest way to ensure that the versions are all good 08:29:59
@kephaspierre:matrix.orgPierre ThierryI'll try that, that's way simpler than anything already shown as example for `shellFor`!10:36:26
@maralorn:maralorn.demaralorn mra: the nixpkgs pin in the nix/ dir should have a commit hash somewhere. You can put that commit hash in the nixpkgs input in the flake. (see nix manual for syntax) 10:36:53
@sternenseemann:systemli.orgsterni (he/him) An alternative is to use callCabal2nix in the packages function which would generate the expression on the fly. (Basically like developPackage, but developPackage would, I think, not work since it behaves differently depending on whether the IN_NIX_SHELL environment variable is set.) 11:36:33
@sternenseemann:systemli.orgsterni (he/him)Pitching the idea to target an upgrade to 9.10.3: https://discourse.nixos.org/t/call-for-contributions-we-are-updating-to-ghc-9-10-2/67756/411:37:36
@teoc:matrix.orgTeo (he/him)That's a good call IMO. There's a pretty annoying in 9.10.2 where GHC will panic if you use a constructor you havent imported but you've imported the synonymous type11:41:56
@alexfmpe:matrix.orgalexfmpewow text 2.1.2 is the gift that keeps on giving13:05:58
@dandart:matrix.orgUraraka ~ Ochaco
In reply to @alexfmpe:matrix.org
wow text 2.1.2 is the gift that keeps on giving
Isn't it just? I use T.show now. I had to change around and not use nix for packages and just use hackage because it wasn't in nix for ages
13:13:36
@maralorn:maralorn.demaralornIt is a very simple change, yes. But we nix maintainers need to wait for it to propagate through every package in the ecosystem to adopt it. And that is one of the many reasons that we can't deliver the deployment speed that you apparently expect.13:57:51
@kephaspierre:matrix.orgPierre Thierry Damnit, all this time, I hadn't see that someone had already added an example of how to add build tools with developPackages… It wasn't there the first time I read that page and I didn't spot the addition. 15:05:13
@kephaspierre:matrix.orgPierre Thierry I'm using direnv-nix and if I put developPackage in my default.nix, nix-build will put the environment in result instead of building the package, is there a way to use developPackage with nix-build within direnv-nix? 15:15:25
@alex:tunstall.xyzAlex
In reply to @kephaspierre:matrix.org
I'm using direnv-nix and if I put developPackage in my default.nix, nix-build will put the environment in result instead of building the package, is there a way to use developPackage with nix-build within direnv-nix?
I'm not sure about what exactly the tool is doing but I suspect that either shell.nix (file preferred by nix-shell) or inNixShell (option automatically enabled by nix-shell) can solve your problem.
15:22:19
@maralorn:maralorn.demaralorngenerally I don’t think that direnv-nix does anything special. If nix-shell works, then direnv-nix should also work.15:24:53
@maralorn:maralorn.demaralornAh, but your problem is the other way around.15:27:04
@maralorn:maralorn.demaralornI actually don’t use developPackage, but the wiki seems pretty clear on how to use it. What you describe should not be happening. You can share your default.nix, then maybe we can see a typo or something.15:28:56
@kephaspierre:matrix.orgPierre Thierry

This is the faulty default.nix:

{ pkgs ? import ./utils/pinned-nixpkgs.nix }: # 24.05

pkgs.haskellPackages.developPackage {
  root = ./.;
  modifier = drv: pkgs.haskell.lib.addBuildTools drv (with pkgs; [ shake haskell-language-server hlint ]);
}
15:47:50
@kephaspierre:matrix.orgPierre Thierry (and it works perfectly fine as shell.nix) 15:48:24
@kephaspierre:matrix.orgPierre Thierry I was hoping I get stop having a separate default.nix and shell.nix, but if default.nix is just pkgs.haskellPackages.callCabal2nix "my-project" ./. {}, that's not a big issue. It's more a question of knowing why this doesn't work at this point. 15:50:09
@maralorn:maralorn.demaralornYeah. I would expect this to just work(TM) as a default.nix with nix-build.15:52:52
@sternenseemann:systemli.orgsterni (he/him) Pierre Thierry: As I've outlined in my response in the thread. developPackage behaves differently based on whether IN_NIX_SHELL is set. direnv presumably inherits this variable when exporting the variables set in the shell environment. nix-build does not unset this environment variable. If you want to continue using developPackage, I'd recommend manually unsetting IN_NIX_SHELL after the use nix directive in .envrc 16:09:49
@sternenseemann:systemli.orgsterni (he/him) This is more or less why I wouldn't recommend using developPackage anymore. It tries to do the right thing magically, but is not very flexible. Also nowadays, code relying on IN_NIX_SHELL (see lib.inNixShell) has become rare (since there is no equivalent in pure-eval, flakes etc. which grow increasingly popular), so users no longer expect this behavior. 16:11:12
@sternenseemann:systemli.orgsterni (he/him)https://nixos.org/manual/nixpkgs/stable/#function-library-lib.trivial.inNixShell now that's a bad docstring16:27:41
@sternenseemann:systemli.orgsterni (he/him)https://github.com/NixOS/nixpkgs/issues/43681417:49:55
@emilazy:matrix.orgemilyit looks like nothing but Haskell uses it?18:06:05
@morgan.arnold:matrix.orgmra Unfortunately, this doesn't seem to straight-up work? If I look in the sources from the template: https://github.com/clash-lang/clash-starters/blob/main/simple-nix/nix/sources.json, and then copy the link to the version of nixpkgs that they used into my flake, I just get a new error: "Package ‘clash-prelude-1.6.6’ in [...] is marked as broken, refusing to evaluate.". Would it be possible to just copy the nix directory into my project, and then import ./nix/nixpkgs.nix or something to use as the nixpkgs input for my flake? 19:22:03
@maralorn:maralorn.demaralornOh, apparently they have a ton of overlays there to fix stuff.20:32:19

Show newer messages


Back to Room ListRoom Version: 6