!RbXGJhHMsnQcNIDFWN:nixos.org

Haskell in Nixpkgs/NixOS

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

Load older messages


SenderMessageTime
2 Mar 2026
@alex:tunstall.xyzAlex
In reply to @iclanzan:matrix.org

I’ve been happily using Haskell for a couple of years through Nix like so:

(pkgs.haskell.packages.ghc910.override {overrides = ...;}).ghcWithPackages(p: [...])

However recently one of my haskell apps started crashing with an exception from time to time. I am hunting for a way to have a call-stack printed for these exceptions. Since I don’t control third party libraries I cannot add HasCallstack to them to be able to debug that way so I have been trying to compile with -prof for the last couple of days with no success.

Does anyone have a working example of how to get this working?

If you really need to, you can override dependencies to tune them to your liking.

But profiling builds are available by default, so if that's all you're after then you only need to tweak the build for the final executable.

What exactly have you tried and how has it failed? The usual Cabal flag should just work.

20:46:31
@iclanzan:matrix.orgiclanzan

I am not using Cabal in my project. Trying to compile with ghc -prof gives an error about ghc not supporting profiling because it was compiled with -dynamic. I tried overriding mkDerivation to add enableLibraryProfiling = true and enableExecutableProfiling = true which caused the tests (check phase) to fail for a lot of libraries so then I added doCheck = false to skip tests. That worked to compile libraries but did not help with ghc. Same error ensued.

Then I tried overriding pkgs.haskell.packages.ghc910.compiler by adding enableProfiledLibs = true to no effect. I then added enableSharedLibraries = false and enableSharedExecutables = false and that cause ghc to fail to compile complaining about missing dynamic object files.

21:04:48
@alex:tunstall.xyzAlex

Works fine for me.

alex@alex-pc3 ~> nix-shell -p ghc --run fish
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> ghc -prof Hello.hs
[1 of 2] Compiling Main             ( Hello.hs, Hello.o )
[2 of 2] Linking Hello
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> ./Hello -RTS -p
Hello, world!
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> cat Hello.prof
	Mon Mar  2 21:25 2026 Time and Allocation Profiling Report  (Final)

	   Hello +RTS -p -s -RTS

	total time  =        0.00 secs   (0 ticks @ 1000 us, 1 processor)
	total alloc =      49,280 bytes  (excludes profiling overheads)

COST CENTRE MODULE                    SRC              %time %alloc

MAIN        MAIN                      <built-in>         0.0   22.7
CAF         GHC.Internal.IO.Handle.FD <entire-module>    0.0   70.5
CAF         GHC.Internal.IO.Encoding  <entire-module>    0.0    5.0
CAF         GHC.Internal.Conc.Signal  <entire-module>    0.0    1.3


                                                                               individual      inherited
COST CENTRE  MODULE                         SRC             no.     entries  %time %alloc   %time %alloc

MAIN         MAIN                           <built-in>      138           0    0.0   22.7     0.0  100.0
 CAF         GHC.Internal.Conc.Signal       <entire-module> 262           0    0.0    1.3     0.0    1.3
 CAF         GHC.Internal.IO.Encoding       <entire-module> 208           0    0.0    5.0     0.0    5.0
 CAF         GHC.Internal.IO.Encoding.Iconv <entire-module> 206           0    0.0    0.4     0.0    0.4
 CAF         GHC.Internal.IO.Handle.FD      <entire-module> 197           0    0.0   70.5     0.0   70.5
 CAF         Main                           <entire-module> 145           0    0.0    0.1     0.0    0.1
21:26:47
@alex:tunstall.xyzAlex

For reproducibility, I should also mention this:

alex@alex-pc3 ~> nixos-version
25.11.2793.89dbf01df72e (Xantusia)
21:28:03
@alex:tunstall.xyzAlex *

Works fine for me.

alex@alex-pc3 ~> nix-shell -p ghc --run fish
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> ghc -prof Hello.hs
[1 of 2] Compiling Main             ( Hello.hs, Hello.o )
[2 of 2] Linking Hello
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> ./Hello +RTS -p
Hello, world!
alex@alex-pc3 nix-shell:/t/nix-shell-1930075-2124826253> cat Hello.prof
	Mon Mar  2 21:25 2026 Time and Allocation Profiling Report  (Final)

	   Hello +RTS -p -RTS

	total time  =        0.00 secs   (0 ticks @ 1000 us, 1 processor)
	total alloc =      49,280 bytes  (excludes profiling overheads)

COST CENTRE MODULE                    SRC              %time %alloc

MAIN        MAIN                      <built-in>         0.0   22.7
CAF         GHC.Internal.IO.Handle.FD <entire-module>    0.0   70.5
CAF         GHC.Internal.IO.Encoding  <entire-module>    0.0    5.0
CAF         GHC.Internal.Conc.Signal  <entire-module>    0.0    1.3


                                                                               individual      inherited
COST CENTRE  MODULE                         SRC             no.     entries  %time %alloc   %time %alloc

MAIN         MAIN                           <built-in>      138           0    0.0   22.7     0.0  100.0
 CAF         GHC.Internal.Conc.Signal       <entire-module> 262           0    0.0    1.3     0.0    1.3
 CAF         GHC.Internal.IO.Encoding       <entire-module> 208           0    0.0    5.0     0.0    5.0
 CAF         GHC.Internal.IO.Encoding.Iconv <entire-module> 206           0    0.0    0.4     0.0    0.4
 CAF         GHC.Internal.IO.Handle.FD      <entire-module> 197           0    0.0   70.5     0.0   70.5
 CAF         Main                           <entire-module> 145           0    0.0    0.1     0.0    0.1
21:29:28
3 Mar 2026
@iclanzan:matrix.orgiclanzan I figured it out. I am using TemplateHaskell and for that to work with -prof I needed to add -fexternal-interpreter. GHC’s error message indicated that as a possible solution but I didn’t explore it. 🤦 01:34:03
4 Mar 2026
@sternenseemann:systemli.orgsterniin this case updating should help recent versions of nixpkgs build cabal2nix against Cabal 3.1421:21:58
5 Mar 2026
@kintrix:matrix.org@kintrix:matrix.org left the room.17:13:04
6 Mar 2026
@nki:m.nkagami.menki ⚡️⚡️ changed their display name from nki ⚡️ to nki ⚡️⚡️.18:41:12
8 Mar 2026
@noiobeforebedtime:winesj.comJack (he/him) changed their display name from Jack​ to Jack (he/him).07:37:36
@ncfavier:matrix.orgncfavier I have a strange situation where building a Haskell package on aarch64-darwin results in more references than expected (as reported by nix-store -q --references), and most of them are not actually present in the output (at least grep -ra doesn't find them). Does this ring a bell for anyone? To reproduce, clone https://github.com/the1lab/1lab and run nix-build -A shakefile. 15:48:14
@alex:tunstall.xyzAlex I recall hearing of a much alike issue before.
Have you looked at the output of nix why-depends --all --precise?
15:52:37
@ncfavier:matrix.orgncfavierThanks, that helped me figure out that the references are through symbolic links, which grep doesn't follow by default.16:01:40
9 Mar 2026
@sternenseemann:systemli.orgsterniI finally discovered what breaks HLS on 9.12.3 and its a bug that has been present in Cabal 3.14 all along, but was masked by a bug that has been fixed in Cabal 3.14.2.0 lol https://github.com/haskell/cabal/issues/1159815:03:54
@sternenseemann:systemli.orgsterni
  • https://github.com/fourmolu/fourmolu/pull/518
  • https://github.com/Bodigrim/cabal-add/pull/10
15:22:44
@sternenseemann:systemli.orgsterni IMO a bad change, though, since it doesn't make sense that build-tool-depends are available at test suite run time. Cabal should have rather added a different mechanism (that has been needed since forever) for this. 15:23:50
@b:chreekat.netchreekatYou typoed the name of the executable on the report to cabal-add :P (you wrote fourmolu)16:11:15
@alexfmpe:matrix.orgalexfmpeOh yay more build-tool-depends annoyances18:13:04
@alexfmpe:matrix.orgalexfmpehttps://github.com/well-typed/haskell-debugger/pull/20318:13:07
@alexfmpe:matrix.orgalexfmpeWhich quickly got reverted because cabal somehow failed to build cabal18:15:21
@alexfmpe:matrix.orgalexfmpehttps://github.com/well-typed/haskell-debugger/issues/20618:16:06
@alexfmpe:matrix.orgalexfmpe* Oh yay more build-tool-depends annoyances. I recently ran into 18:16:34
10 Mar 2026
@sternenseemann:systemli.orgsterni chreekat: well it's forever now… 10:00:30
@adrielus:matrix.orgprescientmoon changed their profile picture.11:07:59
11 Mar 2026
@itamar:apttp.xyzitamar joined the room.00:38:04
@alexfmpe:matrix.orgalexfmpeI'm truly confused... https://github.com/NixOS/nixpkgs/commit/34f316a97a3e0e69bea9b44cd1142f7e73557437 broke haskell.packages.ghc914.haskell-debugger - reverting the commit fixes it the reason is that the older hie-bios's bounds do not build with 9.14 boot libs however, switching back to recent hie-bios in configuration-9.14.nix causes failures in the test suite when building hie-bios??? oddly enough, the older hie-bios does build with jailbreak14:52:55
@alexfmpe:matrix.orgalexfmpe* I'm truly confused... https://github.com/NixOS/nixpkgs/commit/34f316a97a3e0e69bea9b44cd1142f7e73557437 broke haskell.packages.ghc914.haskell-debugger - reverting the commit fixes it the reason is that the older hie-bios's bounds do not build with 9.14 boot libs however, switching back to recent hie-bios in configuration-9.14.nix causes failures in the test suite when building hie-bios??? the older hie-bios does build with jailbreak, doesn't seem like much changed for 9.14: https://github.com/haskell/hie-bios/commits/master/14:53:23
@sternenseemann:systemli.orgsternialexfmpe: you probably lose an override that is otherwise applied to hie-bios19:06:52
@sternenseemann:systemli.orgsternithe order of the overlays matters and it is not always ideal19:07:13
@alexfmpe:matrix.orgalexfmpeAaaah yeah could be, I PR'd jailbreak for now since it works19:12:42

Show newer messages


Back to Room ListRoom Version: 6