Skip to content

If nix-shell <args> fails, Stack just outputs the Nix error #6861

Closed

Description

@mpilgrem

With Nix integration, Stack executes nix-shell with arguments. If the command fails, Stack does not attempt to put that error in any context.

For example, with shell.nix:

{ghc}:
with (import <nixpkgs> {});

haskell.lib.buildStackProject {
  inherit ghc;
  name = "myEnv";
  buildInputs = [ zlib glpk pcre ];
  duff;
}

The output of stack build --nix is just (coloured by Nix):

error: syntax error, unexpected ';', expecting '.' or '='
       at /home/mpilgrem/Code/Haskell/testNic/shell.nix:8:7:
            7|   buildInputs = [ zlib glpk pcre ];
            8|   duff;
             |       ^
            9| }

rather than something like:

Error: [S-1264]
       While using nix-instantiate, with arguments:
       * /home/mpilgrem/Code/Haskell/testNic/shell.nix
       * --arg
       * ghc
       * with (import <nixpkgs> {}); haskell.compiler.ghc9103
       * --argstr
       * ghcVersion
       * ghc9103
       * --show-trace

       Stack encountered the following error:

       error: syntax error, unexpected ';', expecting '.' or '='
              at /home/mpilgrem/Code/Haskell/testNic/shell.nix:8:7:
                   7|   buildInputs = [ zlib glpk pcre ];
                   8|   duff;
                    |       ^
                   9| }

Unfortunately, there is no way to obtain coloured output from Nix commands:

Activity

  1. self-assigned this
    on Mar 14, 2026
  2. added 12 commits that reference this issue on Mar 15, 2026
  3. mpilgrem commented on Mar 18, 2026

    @mpilgrem
    MemberAuthor

    To address this, I separated an initial nix-instantiate step from the final nix-shell step, and introduced separate --nix-instantiate-options=OPTIONS, just in case.

    instantiate shell
    --arg --arg
    --argstr --argstr
    {--attr | -A} {--attr | -A}
    --command
    --run
    --exclude
    --pure
    --keep
    {--packages | -p}
    {[path]}
    files
    {--include | -I} {--include | -I}
    {--expr | -E} {--expr | -E}
    --add-root
  4. maxigit commented on Mar 25, 2026

    @maxigit

    Not related to this issue, but I've seen on discourse that you asked if people where using nix integration : I do and this is one of the (many) reason I am using stack. So please, don't remove it.

  5. added 3 commits that reference this issue on Jul 7, 2026
    675c217
    7bc8087
    d6f6e51
  6. mpilgrem commented on Jul 7, 2026

    @mpilgrem
    MemberAuthor

    @maxigit, as a user of Stack's Nix integration, you may be interested in the associated pull request:

    EDIT: I wrote too soon. My testing has revealed a problem with locales, which I am looking into.

  7. maxigit commented on Jul 8, 2026

    @maxigit

    @mpilgrem Thanks for letting me know. However I moved away from Nix and do my prod build inside a docker container instead ...

  8. added 3 commits that reference this issue on Jul 10, 2026
  9. added a commit that references this issue on Jul 11, 2026
    ff4f7db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions