Skip to content

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

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

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