1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2024-09-20 23:28:26 -04:00
Commit graph

1717 commits

Author SHA1 Message Date
Ben Burdette 71da988d47 more debug removal 2021-10-22 14:34:50 -06:00
Ben Burdette e54f17eb46 remove more debug code 2021-10-22 14:27:04 -06:00
Ben Burdette cbc2f0fe31 remove dead code 2021-10-22 14:02:47 -06:00
Ben Burdette 427fb8d158 comment out debugs 2021-10-11 16:48:10 -06:00
Ben Burdette 98eb13691a print staticenv bindings 2021-10-11 16:32:43 -06:00
Ben Burdette 2ee1fa4afd add nullable Expr argument 2021-10-11 14:42:29 -06:00
Ben Burdette aad27143c6 storing staticenv bindings 2021-10-02 13:47:36 -06:00
Ben Burdette b9d08b98da ok was unconditoinally throwing on any With var 2021-09-23 13:02:39 -06:00
Ben Burdette c07edb1932 staticenv should be With 2021-09-22 18:14:57 -06:00
Ben Burdette c7e3d830c1 more debug stuff 2021-09-22 16:22:53 -06:00
Ben Burdette cd8c232b55 add cout debugging 2021-09-15 16:16:53 -06:00
Ben Burdette 21071bfdeb shared_ptr for StaticEnv 2021-09-14 10:49:22 -06:00
Ben Burdette 176911102c printEnvPosChain 2021-09-13 11:57:25 -06:00
Ben Burdette 310c689d31 remove more explicit valmap code 2021-08-25 13:18:27 -06:00
Ben Burdette d8a977a22e adding all the value names from env.values[0] 2021-08-25 11:19:09 -06:00
Ben Burdette bd3b5329f9 print env bindings 2021-08-24 16:32:54 -06:00
Ben Burdette 4b5f9b35f0 env to bindings 2021-08-18 21:25:26 -06:00
Ben Burdette 2272021536 more error fixes 2021-08-18 20:02:23 -06:00
Ben Burdette e82cf13b1e switch to fakeenvs 2021-08-18 17:53:10 -06:00
Ben Burdette b6eb38016b moving towards env in exceptions 2021-08-17 14:39:50 -06:00
Ben Burdette 030271184f trying env args; but unecessary? 2021-08-09 14:30:47 -06:00
Ben Burdette 89264d20e6 move valmap to hh; add to env 2021-08-06 11:09:27 -06:00
Ben Burdette 129dd760e6 mapEnvBindings 2021-06-11 18:55:15 -06:00
Ben Burdette d22de1dd0c remove dead code 2021-06-09 15:38:08 -06:00
Ben Burdette 93ca9381da formatting; string arg for throwTypeError 2021-06-08 18:37:28 -06:00
Ben Burdette ebf530d31e line endings 2021-06-08 18:17:58 -06:00
Ben Burdette ff2e72054f another throwTypeError form 2021-06-08 14:44:41 -06:00
Ben Burdette 99304334ca showType(fun) 2021-05-14 18:09:30 -06:00
Ben Burdette 644567cf7e clean up w LocalNoInline macro 2021-05-14 13:40:00 -06:00
Ben Burdette 17af7dc326 throwAssertionError, throwUndefinedError -> valmap-ized 2021-05-14 11:29:26 -06:00
Ben Burdette d041dd874e throwEvalError form 4 2021-05-14 11:15:24 -06:00
Ben Burdette ed74eaa07f throwEvalError form 3 2021-05-14 11:09:18 -06:00
Ben Burdette 989a4181a8 throwEvalError form 2 2021-05-14 11:06:20 -06:00
Ben Burdette ab19d1685d throwEvalError; mapBindings 2021-05-13 16:00:48 -06:00
Ben Burdette 459bccc750 plain env pointer 2021-05-12 11:33:31 -06:00
Ben Burdette 0c2265da85 unique_ptr for valmap 2021-05-12 09:43:58 -06:00
Ben Burdette e7847ad7a1 map1/2 for stack usage 2021-05-11 15:38:49 -06:00
Ben Burdette a8fef9a6b1 throwTypeError with debugger/env 2021-05-10 18:36:57 -06:00
Ben Burdette 2dd61411af debugger on autoCallFunction error 2021-05-03 14:37:33 -06:00
Ben Burdette 57c2dd5d85 fixes 2021-04-28 09:55:08 -06:00
Ben Burdette b466d51952 Merge branch 'master' into debugger-merge 2021-04-27 12:31:01 -06:00
Domen Kožar e3e78ee2a2
Merge pull request #4751 from Ma27/storepath-pos
primops/storePath: add trace to pure mode error
2021-04-27 19:05:23 +02:00
Maximilian Bosch e6a360a4d9
primops/storePath: add trace to pure mode error
As described in #4745 it's otherwise fairly hard to understand where
this is coming from. Say you have an expression which uses e.g.
`types.package`:

``` nix
{ outputs = { self, nixpkgs }: {
    packages.x86_64-linux.hello = let
      foo = nixpkgs.lib.evalModules {
        modules = [
          {
            options.foo.bar = with nixpkgs.lib; mkOption { type = types.package; };
          }
          {
            foo.bar = ./.;
          }
        ];
      };
    in builtins.trace foo.config.foo.bar.outPath nixpkgs.legacyPackages.x86_64-linux.hello;
    defaultPackage.x86_64-linux = self.packages.x86_64-linux.hello;
  };
}
```

Then you'll get an error trace like this:

```
error: 'builtins.storePath' is not allowed in pure evaluation mode

       at /nix/store/p4h2x6r80njkb0j2rc1xjhhl99yri3zb-source/lib/attrsets.nix:328:15:

          327|     let
          328|       path' = builtins.storePath path;
             |               ^
          329|       res =

       … while evaluating the attribute 'config.foo.bar.outPath'

       at /nix/store/p4h2x6r80njkb0j2rc1xjhhl99yri3zb-source/lib/attrsets.nix:332:11:

          331|           name = sanitizeDerivationName (builtins.substring 33 (-1) (baseNameOf path'));
          332|           outPath = path';
             |           ^
          333|           outputs = [ "out" ];

       … while evaluating the attribute 'packages.x86_64-linux.hello'

       at /nix/store/6c1rfsqzrhjw1235palzjmf5vihcpci7-source/flake.nix:3:5:

            2| { outputs = { self, nixpkgs }: {
            3|     packages.x86_64-linux.hello = let
             |     ^
            4|       foo = nixpkgs.lib.evalModules {
```

Fixes #4745
2021-04-27 17:24:38 +02:00
regnat 31313d1401 Replace the trailing markdown spaces by a backslash
They are equivalent according to
<https://spec.commonmark.org/0.29/#hard-line-breaks>,
and the trailing spaces tend to be a pain (because the make git
complain, editors tend to want to remove them − the `.editorconfig`
actually specifies that − etc..).
2021-04-23 14:37:21 +02:00
Eelco Dolstra 293220bed5
Merge pull request #4440 from Ma27/misc-pos-fixes
Miscellaneous improvements for positioning in eval-errors
2021-04-23 11:10:59 +02:00
Maximilian Bosch 6905291daf
libcmd/installables: force re-evaluation of cached failures
I think that it's not very helpful to get "cached failures" in a wrong
`flake.nix`. This can be very confusing when debugging a Nix expression.
See for instance NixOS/nixpkgs#118115.

In fact, the eval cache allows a forced reevaluation which is used for
e.g. `nix eval`.

This change makes sure that this is the case for `nix build` as well. So
rather than

    λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes'
    error: cached failure of attribute 'defaultPackage.x86_64-linux'

the evaluation of already-evaluated (and failed) attributes looks like
this now:

    λ ma27 [~/Projects/exp] → ../nix/outputs/out/bin/nix build -L --rebuild --experimental-features 'nix-command flakes'
    error: attribute 'hell' missing

           at /nix/store/mrnvi9ss8zn5wj6gpn4bcd68vbh42mfh-source/flake.nix:6:35:

                5|
                6|     packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hell;
                 |                                   ^
                7|
    (use '--show-trace' to show detailed location information)
2021-04-19 19:51:04 +02:00
Maximilian Bosch 864ef0e93d
libexpr/primops: review 2021-04-13 23:12:39 +02:00
Maximilian Bosch ad7b47dc85
primops/libexpr: use new attr-call extractor everywhere; use function's pos if attr-set pos == noPos 2021-04-13 23:12:38 +02:00
Maximilian Bosch f60473a077
libexpr/primops: Move attr name extraction into its own function
This now takes care of providing positioning for both the faulting value
and the faulting function call in case of an error.
2021-04-13 23:12:38 +02:00
Maximilian Bosch 7c76964daa
libexpr: misc improvements for proper error position
When working on some more complex Nix code, there are sometimes rather
unhelpful or misleading error messages, especially if coerce-errors are
thrown.

This patch is a first steps towards improving that. I'm happy to file
more changes after that, but I'd like to gather some feedback first.

To summarize, this patch does the following things:

* Attrsets (a.k.a. `Bindings` in `libexpr`) now have a `Pos`. This is
  helpful e.g. to identify which attribute-set in `listToAttrs` is
  invalid.

* The `Value`-struct has a new method named `determinePos` which tries
  to guess the position of a value and falls back to a default if that's
  not possible.

  This can be used to provide better messages if a coercion fails.

* The new `determinePos`-API is used by `builtins.concatMap` now. With
  that change, Nix shows the exact position in the error where a wrong
  value was returned by the lambda.

  To make sure it's still obvious that `concatMap` is the problem,
  another stack-frame was added.

* The changes described above can be added to every other `primop`, but
  first I'd like to get some feedback about the overall approach.
2021-04-13 23:12:38 +02:00