Stack on NixOS

I had configured stack as a system package on NixOS/Plasma. That provided stack --version of 3.9.3 x86_64 hpack-0.39.1, the NixOS project’s version of Stack 3.9.3. On NixOS, Stack’s nix: enable configuration option defaults to true. That means that Stack uses Nix to manage GHC versions and builds, by default, in a pure Nix shell.

Building Stack with Stack

I tried to build the master branch version of Stack with Stack. It failed. First, because digest, a dependency of stack, required the tool pkg-config. That is provided by the Nix package of the same name. I added it to the list of Stack’s nix: packages configuration option. digest also needs the Nix package zlib.

Second, it failed when Cabal attempted to build lib:stack and exe:stack, specifically when trying to compile System/Terminal_hsc_make.c with cc, which failed with posix_spawn: Argument list too long.

This appears to be due to a know bug in Cabal, which has been fixed but left out of subsequent released versions of Cabal (to date).