tvix/eval: suppport relative paths

#317
Opened by flokli at 2023-10-06T11·18+00

    --> [code]:1:1
     |
1    | (import ./derivation-attr-paths.nix) { } # uses <nixpkgs>
     | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (concatLists)
    --> /home/flokli/dev/nixos/code.tvl.fyi-submit3/tvix/derivation-attr-paths.nix:37:49
     |
37   |             ] else if recurseInto path value then lib.concatLists (
     |  _________________________________________________^
38   | |             lib.mapAttrsToList (n: go (path ++ [ n ])) value
39   | |           ) else [];
     | |___________^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/code.tvl.fyi-submit3/tvix/derivation-attr-paths.nix:34:11
     |
34   | /           if !success then []
35   | |           else if lib.isDerivation value then [
36   | |             path
37   | |           ] else if recurseInto path value then lib.concatLists (
37   | |           ] else if recurseInto path value then lib.concatLists (
39   | |           ) else [];
     | |___________________^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/code.tvl.fyi-submit3/tvix/derivation-attr-paths.nix:34:14
     |
34   |           if !success then []
     |              ^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/code.tvl.fyi-submit3/tvix/derivation-attr-paths.nix:29:20
     |
29   |           inherit (builtins.tryEval x)
     |                    ^^^^^^^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:86:7
     |
86   | /       if builtins.isAttrs result then
87   | |         result // {
88   | |           override = overrideArgs;
89   | |           overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
...    |
97   | |         }
98   | |       else result;
     | |_________________^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:86:10
     |
86   |       if builtins.isAttrs result then
     |          ^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/applications/science/misc/colmap/default.nix:6:1
     |
6    | / assert cudaSupport -> cudaPackages != { };
7    | |
8    | | let
9    | |   boost_static = boost179.override { enableStatic = true; };
...    |
53   | |   };
54   | | }
     | |_^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/applications/science/misc/colmap/default.nix:6:8
     |
6    | assert cudaSupport -> cudaPackages != { };
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/applications/science/misc/colmap/default.nix:6:23
     |
6    | assert cudaSupport -> cudaPackages != { };
     |                       ^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/applications/science/misc/colmap/default.nix:6:23
     |
6    | assert cudaSupport -> cudaPackages != { };
     |                       ^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/attrsets.nix:1019:5
     |
1019 |     attrs // { recurseForDerivations = true; };
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/attrsets.nix:1019:5
     |
1019 |     attrs // { recurseForDerivations = true; };
     |     ^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:86:7
     |
86   | /       if builtins.isAttrs result then
87   | |         result // {
88   | |           override = overrideArgs;
89   | |           overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
...    |
97   | |         }
98   | |       else result;
     | |_________________^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:86:10
     |
86   |       if builtins.isAttrs result then
     |          ^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:269:16
     |
269  |       let self = f self // {
     |  ________________^
270  | |           newScope = scope: newScope (self // scope);
271  | |           callPackage = self.newScope {};
272  | |           overrideScope = g: makeScope newScope (lib.fixedPoints.extends g f);
...    |
277  | |           packages = f;
278  | |         };
     | |_________^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/customisation.nix:269:16
     |
269  |     let self = f self // {
     |                ^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:91:58
     |
91   |   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
     |                                                          ^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:91:67
     |
91   |   extends = f: rattrs: self: let super = rattrs self; in super // f self super;
     |                                                                   ^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:10
     |
102  |       in fApplied // g final prev';
     |          ^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:22
     |
102  |       in fApplied // g final prev';
     |                      ^^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:10
     |
102  |       in fApplied // g final prev';
     |          ^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:22
     |
102  |       in fApplied // g final prev';
     |                      ^^^^^^^^^^^^^
note: while evaluating this Nix code
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:10
     |
102  |       in fApplied // g final prev';
     |          ^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (force)
    --> /home/flokli/dev/nixos/nixpkgs/lib/fixed-points.nix:102:10
     |
102  |       in fApplied // g final prev';
     |          ^^^^^^^^
note: while evaluating this as native code (listToAttrs)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/development/compilers/cudatoolkit/redist/extension.nix:132:24
     |
132  |       redistPackages = listToAttrs (concatMap wrapper (attrNames manifest));
     |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (concatMap)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/development/compilers/cudatoolkit/redist/extension.nix:132:37
     |
132  |       redistPackages = listToAttrs (concatMap wrapper (attrNames manifest));
     |                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (attrNames)
    --> /home/flokli/dev/nixos/nixpkgs/pkgs/development/compilers/cudatoolkit/redist/extension.nix:132:56
     |
132  |       redistPackages = listToAttrs (concatMap wrapper (attrNames manifest));
     |                                                        ^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (foldl')
    --> /home/flokli/dev/nixos/nixpkgs/lib/trivial.nix:63:8
     |
63   |     in builtins.foldl' reverseApply val functions;
     |        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
note: while evaluating this as native code (fromJSON)
    --> /home/flokli/dev/nixos/nixpkgs/lib/trivial.nix:313:5
     |
313  |     builtins.fromJSON (builtins.readFile path);
     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error[E020]: string './manifests/redistrib_11.8.0.json' does not represent an absolute path
    --> /home/flokli/dev/nixos/nixpkgs/lib/trivial.nix:313:24
     |
313  |     builtins.fromJSON (builtins.readFile path);
     |                        ^^^^^^^^^^^^^^^^^^^^^^

(Using the example from https://b.tvl.fyi/issues/281 on a NIX_PATH=nixpkgs=path/to/checkout with https://github.com/NixOS/nixpkgs/pull/259365 applied)

  1. My PR was broken in a different fashio, the error behaviour actually matches Nix 2.3. Sorry for the noise.

    flokli at 2023-10-06T12·08+00

  2. flokli closed this issue at 2023-10-06T12·08+00