Users of Stack and Nix: seeking feeback on sensible defaults

Users of both Stack and the Nix package manager, I am seeking feedback on sensible defaults for Stack, as follows:

  • On the NixOS operating system, Stack’s Nix integration is currently enabled by default. Is that still sensible? I understand that the Nix project advises Stack users not to use its Nix integration, but take a different route.

  • Stack’s Nix integration, when enabled, implies --system-ghc (prefer a ‘system’ GHC executable on the PATH (e.g. one in the Nix environment) to a Stack-supplied GHC executable) and --install-ghc (seek to download and install the specified GHC version, if it is not already available). Is --install-ghc a sensible default with Nix integration? Should it be --no-install-ghc (eg fail, if Nix does not have the specified GHC version)?

More radically, is anyone actually using Stack’s Nix integration? I’ve been asked to consider dropping it. However, I would not contemplate that if people are using it; Stack’s Nix integration is easy to support and does not ‘get in the way’ for non-users of the integration.

3 Likes

Hello @mpilgrem,

As a user on NixOS and former maintainer of HaskellR (stack + nix project), I don’t feel strong about these defaults.

More radically, is anyone actually using Stack’s Nix integration?

HaskellR still uses the integration, but I think it would be easy enough to replace it with

nix-shell --run “stack --system-ghc build”

if it were dropped.

2 Likes

In my experience, the nix integration in stack is a footgun that I have always wanted to turn off.

In general, when using nix, I tend to have a nix-shell which provides both stack and ghc along with all my C dependencies.

I think fundamentally what this integration is trying to do is a layering violation. You normally want nix to be the top layer (for managing system packages) and then for stack to be below that (for managing Haskell packages). This tries to do magic that violates this and I just don’t think that can work well, especially if you are in a multi-language context where let’s say you also want to have some nodejs things installed by nix.

So, I would be in favour of removing this integration.

7 Likes

I completely agree. I always wondered why it was there in the first place.