Nix recipes for Haskellers

I’m finalizing my short tutorial on Nix for Haskell programmers. If you are a Haskell programmer, and if you feel like something could be explained in this tutorial, please let me know!

https://www.srid.ca/haskell-nix.html

7 Likes

Nice! Some comments how to improve further:

  • inline shebang snippet
  • haskell.nix for more complicated setups
2 Likes

Thanks! I’ve improved in the article taking your two comments.

1 Like

Thanks for this work ! I’m struggling with stack thus I would be interested to read more about how it relates to Nix. However it may not be part of the topic you want to cover…

Have you tried adding a default.nix (as the article suggests here) to your exercism exercise project, and used exclusively Nix (no stack) to build it?

Basically,

  1. Add default.nix using the snippet in the article
  2. Run nix-shell --run ghcid

(ghcid will recompile as you edit the sources)

If you use ghcid -T main it will even run it.

I will try it, thanks.

nix-shell --run ghcid outputs same error as with stack

stm        > /run/user/1000/stack-7a9824c190b5454b/stm-2.4.5.0/Control/Monad/STM.hs:34:9: error: Not in scope: ‘always’
stm        >    |
stm        > 34 |         always,
stm        >    |         ^^^^^^
stm        > 
stm        > /run/user/1000/stack-7a9824c190b5454b/stm-2.4.5.0/Control/Monad/STM.hs:35:9: error: Not in scope: ‘alwaysSucceeds’
stm        >    |
stm        > 35 |         alwaysSucceeds,
stm        >    |         ^^^^^^^^^^^^^^

Error: 
--  While building package stm-2.4.5.0 using:
      /home/jlucas/.stack/setup-exe-cache/x86_64-linux-nix/Cabal-simple_mPHDZzAJ_2.4.0.1_ghc-8.6.5 --builddir=.stack-work/dist/x86_64-linux-nix/Cabal-2.4.0.1 build --ghc-options ""
    Process exited with code: ExitFailure 1

This seems like an error with the cabal configuration of the project, doesn’t it ? (I am a newbie with cabal and stack).