It's hard to track where a source came from inside the evaluator #669

Open
opened 2025-02-12 18:41:47 +00:00 by jade · 4 comments
Owner

Raised from #668: if you have some store path with busted nix code in it, it's really hard to find the code that fetched it to figure out why it even got evaluated. We can surely store that information in the evaluator and surface it somehow (maybe in stack traces?).

This is especially true of flakes where the path is just "source", which is useless. It should give the attr path from which it came.

Raised from https://git.lix.systems/lix-project/lix/issues/668: if you have some store path with busted nix code in it, it's really hard to find the code that fetched it to figure out why it even got evaluated. We can surely store that information in the evaluator and surface it somehow (maybe in stack traces?). This is especially true of flakes where the path is just "source", which is useless. It should give the attr path from which it came.
jade added this to the Error reporting project 2025-02-12 18:41:47 +00:00
Owner

the issue in #668 was even worse since the problematic code came in via an imperative nixpkgs overlay. provenance tracking that can detangle this mess is going to be extremely costly :( probably not a large issue is we can make it free unless a special flag is given, but oof.

the issue in #668 was even worse since the problematic code came in via an imperative nixpkgs overlay. provenance tracking that can detangle this mess is going to be extremely costly :( probably not a large issue is we can make it free unless a special flag is given, but oof.
Author
Owner

I think theoretically we could track it as a map from each individual store path going into the evaluation to the positions it's from, or so. So the cost would be just related to the total number of store paths in the evaluation and then the usage side is only when there's failures or debugging happening.

I think theoretically we could track it as a map from each individual store path going into the evaluation to the positions it's from, or so. So the cost would be just related to the total number of store paths in the evaluation and then the usage side is only when there's failures or debugging happening.
Owner

with @piegames's position tracking improvements that haven't landed yet we'll also have the position of the path expression in source. if we were to just add an error frame to import and show two innermost frames stack frames instead of just one we could have something like

       … while importing nix code referenced here
         at /home/git/nixpkgs/pkgs/top-level/impure.nix:59:17
           58|          # it's a file, so the result is the contents of the file itself
           59|          import path;
             |                 ^
           60|    in

       error: URL literals are deprecated, allow using them with --extra-deprecated-features url-literals
       at /nix/store/rnglp5cjwkd406is981cvbghd0j8bmv8-source/firefox-overlay.nix:18:34:
           17|   firefox_versions = with builtins;
           18|     fromJSON (readFile (fetchurl https://product-details.mozilla.org/1.0/firefox_versions.json));
             |                                  ^
           19|

instead of

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: URL literals are deprecated, allow using them with --extra-deprecated-features url-literals
       at /nix/store/rnglp5cjwkd406is981cvbghd0j8bmv8-source/firefox-overlay.nix:18:34:
           17|   firefox_versions = with builtins;
           18|     fromJSON (readFile (fetchurl https://product-details.mozilla.org/1.0/firefox_versions.json));
             |                                  ^
           19|
with @piegames's position tracking improvements that haven't landed yet we'll also have the position of the path expression in source. if we were to just add an error frame to import and show *two* innermost frames stack frames instead of just one we could have something like ``` … while importing nix code referenced here at /home/git/nixpkgs/pkgs/top-level/impure.nix:59:17 58| # it's a file, so the result is the contents of the file itself 59| import path; | ^ 60| in error: URL literals are deprecated, allow using them with --extra-deprecated-features url-literals at /nix/store/rnglp5cjwkd406is981cvbghd0j8bmv8-source/firefox-overlay.nix:18:34: 17| firefox_versions = with builtins; 18| fromJSON (readFile (fetchurl https://product-details.mozilla.org/1.0/firefox_versions.json)); | ^ 19| ``` instead of ``` (stack trace truncated; use '--show-trace' to show the full trace) error: URL literals are deprecated, allow using them with --extra-deprecated-features url-literals at /nix/store/rnglp5cjwkd406is981cvbghd0j8bmv8-source/firefox-overlay.nix:18:34: 17| firefox_versions = with builtins; 18| fromJSON (readFile (fetchurl https://product-details.mozilla.org/1.0/firefox_versions.json)); | ^ 19| ```
Author
Owner

Related: #625

Related: https://git.lix.systems/lix-project/lix/issues/625
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#669
No description provided.