!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

681 Members
For discussions and questions about Haskell with Nix, cabal2nix and haskellPackages in nixpkgs | Current Docs: https://nixos.org/manual/nixpkgs/unstable/#haskell | Current PR: https://github.com/nixos/nixpkgs/pulls?q=is%3Apr+is%3Aopen+head%3Ahaskell-updates | Maintainer Docs: https://github.com/NixOS/nixpkgs/blob/haskell-updates/pkgs/development/haskell-modules/HACKING.md | More Nix: #community:nixos.org | More Haskell: #haskell-space:matrix.org | Merger Schedule: https://cloud.maralorn.de/apps/calendar/p/H6migHmKX7xHoTFa/dayGridMonth/now | Join #haskell.nix:libera.chat for question about the alternative haskell.nix infrastructure133 Servers

Load older messages


SenderMessageTime
23 Aug 2025
@kephaspierre:matrix.orgPierre Thierry
In reply to @magthe:tchncs.de
This is how I do it. At least at the moment, things change as I learn more Nix.
https://gitlab.com/magus/nix-setups/-/tree/main/hs-shell?ref_type=heads
I finally found a way where I wrote the least possible amount in my shell.nix, I do import project.nix (I run cabal2nix . > project.nix when my cabal file changes), and I use builtins.functionArgs to see every package I need, and use that in a pkgs.mkShell { packages = [ pkgs.hlint pkgs.haskell-language-server (pkgs.haskellPackages.ghcWithPackages getDeps)]
23:26:40
24 Aug 2025
@sternenseemann:systemli.orgsterni if you have the generated file you can just use haskell.packages.${your-pkg-set}.shellFor { packages = p: [ (p.callPackage ./project.nix { }) ]; nativeBuildInputs = [ /* other tools */ ]; }. 14:10:00
@dandart:matrix.orgUraraka ~ OchacoI no longer use nix for haskell packages, they're always out of date with hackage, so I just have my shell.nix including the correct ghc and cabal and then use cabal for the rest14:34:34
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.19:10:01
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.23:20:56
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.23:24:20
25 Aug 2025
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.03:00:52
@ashinnv:matrix.orgMagnolia Mayhem changed their profile picture.03:01:08
@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 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.orgsterniPitching 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 (they/he)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

Show newer messages


Back to Room ListRoom Version: 6