vm: coerce the path builtin's path argument like Nix's coerceToPath - #10
vm: coerce the path builtin's path argument like Nix's coerceToPath#10dan-v wants to merge 1 commit into
Conversation
builtins.path rejected an attrset path argument with a type error; Nix's prim_path routes it through coerceToPath, which takes paths and strings directly and coerces anything else without store copies (an attrset via outPath or __toString), then requires an absolute result. Passing a flake input or derivation-like value as path is a common idiom. Route the path attribute through the existing non-copying string coercion; the absolute-path requirement and the other attributes are unchanged. Verified against nix-instantiate: outPath-as-path, outPath-as-string, and __toString arguments all produce the identical store path Nix produces. A unit test pins the three vectors against the plain-string argument.
|
Merged as Three follow-up commits on top. The third one is the crash you would have hit next: a cyclic The derivation-specific coercion clones still recurse unguarded; #8 covers those and can adopt |
Problem
builtins.pathrejects an attrsetpathargument with a type error. Nix'sprim_pathroutes it throughcoerceToPath: paths and strings directly,__toStringrecursively, anything else through the non-copying string coercion (an attrset viaoutPath), then requires an absolute result. Passing a flake input or derivation-like value aspathis a common idiom.Fix
Route the
pathattribute through the existing non-copying string coercion (stringLikeValue, whose__toString-before-outPathordering matchescoerceToPath). The absolute-path requirement and the other attributes are unchanged.Verification
outPath-as-path,outPath-as-string,__toString, and a non-canonical/x/../.argument all produce the store path Nix produces, byte-identical.