!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

710 Members
For discussions and questions about Haskell with Nix, cabal2nix and haskellPackages in nixpkgs | Current Docs: https://haskell4nix.readthedocs.io/140 Servers

Load older messages


SenderMessageTime
24 Jul 2025
@maralorn:maralorn.demaralorn @keetonbrewster:matrix.org haskell4nix.readthedocs.io is outdated. It's uptodate version is the nixpkgs manual Haskell section. 06:07:02
@maralorn:maralorn.demaralorn
In reply to @bglgwyng:matrix.org
Hello! I'm trying to build a nixpkgs.haskellPackages from an arbitrary stackage snapshot. I just found regenerate-hackage-packages.sh in nixpkgs and also hackage2nix in cabal2nix. Is hackage2nix enough for my purpose? I don't fully understand how two tools differ.
Huh, I don't think we expect downstream users of hackage2nix. I fear that you won't get very far. But if you really want do this the easiest way would probably be to look at the update stackage script in nixpkgs modify it to not use the newest but your desired snapshot, run it and then run the regenerate script. You can think of the regenerate script as running hackage2nix with all correct configuration for nixpkgs in place. Running hackage2nix without it would probably require duplicating parts of it.
06:15:22
@bglgwyng:matrix.orgbglgwyng What if I want to avoid making my own version of nixpkgs? I prefer more local apporach such as generating .nix file that can be used to replace nixpkgs.haskellPackage. Can I do the same thing using 'regenerate-hackage-packages'? 06:45:03
@maralorn:maralorn.demaralornIt's not meant to be used that way, no. But maybe you can take it as an inspiration. Maybe you want to have a look at stacklock2nix it might be closer to your needs.06:47:25
@bglgwyng:matrix.orgbglgwyngDo you mean https://github.com/cdepillabout/stacklock2nix this repo?06:59:05
@maralorn:maralorn.demaralorn
In reply to @keetonbrewster:matrix.org
Hi everyone, is there a Haskell specific Nix beginner guide out there?
That reminds me. I actually did a talk about that at zurihac. It might be helpful: https://m.youtube.com/watch?v=xOjKAatxD_g&list=PLOvRW_utVPVlFEXuyaIVILO1t_48e4Ai2&index=9&pp=iAQB
06:59:34
@bglgwyng:matrix.orgbglgwyngIndeed, I tried an approach using 'plan.json', cabal dry run generates plan.json and nix fetches the source code, however it caused too frequent rebuild of existing library. So I'm looking for a way to pre-bake package set.07:01:47
@maralorn:maralorn.demaralorn
In reply to @maralorn:maralorn.de
That reminds me. I actually did a talk about that at zurihac. It might be helpful: https://m.youtube.com/watch?v=xOjKAatxD_g&list=PLOvRW_utVPVlFEXuyaIVILO1t_48e4Ai2&index=9&pp=iAQB
It's sadly not super structured or dense, but I actually think we covered a lot of useful information.
07:04:59
@mangoiv.:matrix.orgMangoIVHey guys. what is the current status of static linking with ghc? Is ghc 9.4.8 still the only supported compiler? 08:51:07
@sternenseemann:systemli.orgsterni (he/him)all GHCs work, but TemplateHaskell isn't supported for >= 9.610:02:35
@teoc:matrix.orgTeo (he/him) out of interest, is there a ticket that tracks this? 10:38:26
@teoc:matrix.orgTeo (he/him) found it: https://github.com/NixOS/nixpkgs/issues/275304 10:38:45
@mangoiv.:matrix.orgMangoIV teo (they/he): I will try out with your patch and report back. thank you! 12:44:14
25 Jul 2025
@mequbic:matrix.orgiqubic (she/her)Hmm... I think I might be doing something wrong. So I have this bare-bones starter project of mine: https://github.com/IQubic/mandelbrot00:10:59
@mequbic:matrix.orgiqubic (she/her)

And entering the nix-shell works. But then attempting to run cabal repl fails with this:

Resolving dependencies...
Error: [Cabal-7107]
Could not resolve dependencies:
[__0] next goal: mandelbrot (user goal)
[__0] rejecting: mandelbrot-0.1.0.0 (conflict: requires GHC2024 which is not supported)
[__0] fail (backjumping, conflict set: mandelbrot)
After searching the rest of the dependency tree exhaustively, these were the goals I've had most trouble fulfilling: mandelbrot
00:12:02
@mequbic:matrix.orgiqubic (she/her) Does cabal not support GHC2024 yet? 00:12:13
@le:4d2.org@le:4d2.org
In reply to @mequbic:matrix.org
Does cabal not support GHC2024 yet?

GHC2024 is only supported if you have at least version 9.10 of ghc, according to a warning when initialising projects with cabal. nix installs 9.8.4 by default though.

When I explicitly install a newer version using nix-shell -p cabal-install haskell.compiler.ghc9122, which installs ghc version 9.12.2, it works.

(Well "works": I get a different error, which could be resolved with changing base ^>= 4.19.2.0 to base >= 4.19.2.0 in mandelbrot.cabal, but that's a different topic)

05:49:07
@le:4d2.org@le:4d2.org
In reply to @le:4d2.org

GHC2024 is only supported if you have at least version 9.10 of ghc, according to a warning when initialising projects with cabal. nix installs 9.8.4 by default though.

When I explicitly install a newer version using nix-shell -p cabal-install haskell.compiler.ghc9122, which installs ghc version 9.12.2, it works.

(Well "works": I get a different error, which could be resolved with changing base ^>= 4.19.2.0 to base >= 4.19.2.0 in mandelbrot.cabal, but that's a different topic)

To have all of this in your shell.nix, change

myPkg = pkgs.haskellPackages.callCabal2nix "mandelbrot" src {};

to

myPkg = pkgs.haskell.packages.ghc9122.callCabal2nix "mandelbrot" src {};
05:55:45
@aidalgol:matrix.orgaidalgol I need some help understanding this build failure from PR 424162. 06:12:38
@alex:tunstall.xyzAlex
In reply to @aidalgol:matrix.org
I need some help understanding this build failure from PR 424162.
It looks like 8 test failures caused by an attempt to run a missing or not found program.
Check the source code to see what it's trying to execute and try to add it to the test dependencies.
Since these appear to be doctests, they might be failing because the build doesn't have the necessary tools to run doctests available.
08:22:40
@mangoiv.:matrix.orgMangoIV teo (they/he): which hadrian needs your patch? The boot compiler or the actual compiler? (the patch only applies to ghc 9.10 but not to 9.12...) 10:59:43
@teoc:matrix.orgTeo (he/him) should be actual compiler, I can rebase my patch for ghc-9.12 13:03:01
@mangoiv.:matrix.orgMangoIV
In reply to @teoc:matrix.org
should be actual compiler, I can rebase my patch for ghc-9.12
I fear then it won’t apply to earlier versions. Building with ghc 9.10 but can only continue when my laptop is idle because while it’s building GHCs it’s unusable
13:04:03
@mangoiv.:matrix.orgMangoIV😌13:04:07
@mangoiv.:matrix.orgMangoIV
In reply to @mangoiv.:matrix.org
I fear then it won’t apply to earlier versions. Building with ghc 9.10 but can only continue when my laptop is idle because while it’s building GHCs it’s unusable
Okay so applying the patch didn’t do anything, still doesn’t build, with the same error, cc teo (they/he)
14:55:24
@teoc:matrix.orgTeo (he/him) thanks for looking! I'll look into this more at some point soon 14:57:21
@maralorn:maralorn.demaralornI would like to conceptually grok how cross-compilation works in nixpkgs. My understanding is that "buildPackages" is meant to contain build outputs which are meant to be used on the build system, and they can be used to produce build outputs meant to be run on the target system. What I am wondering is this: When we want to cross-compile to wasm then we need to take a ghc which has wasm als compile target. But that ghc I think runs on the build system and thus belongs to buildPackages right? But when we replace the ghc in buildPackages with a wasm-targeting one, then those haskellBuildPackages are kinda broken because they should be compiled for and usable on the build plattform, so "replacing" the ghc is kinda wrong is it? I am asking because I am trying to understand this line: https://github.com/ners/nix-wasm/blob/795efcfb8f8e98d7084be5da354cbe850f5834da/flake.nix#L48 Which works, but it does e.g. lead to ghcWithPackages not working for wasm cross.23:24:27
@maralorn:maralorn.demaralornBut of course the error might be somewhere else. This has all so many moving parts and I am trying to learn the concepts.23:25:19
26 Jul 2025
@emilazy:matrix.orgemily buildPackages is pkgsBuildBuild 01:56:32
@emilazy:matrix.orgemily packages that run on buildPlatform and target (when they are compilers) buildPlatform 01:56:44

Show newer messages


Back to Room ListRoom Version: 6