nix-stdlib icon indicating copy to clipboard operation
nix-stdlib copied to clipboard

types.paths.toType behavior for relative pathnames

Open 4z3 opened this issue 3 years ago • 0 comments

Describe the bug

When using types.paths.toType with relative pathnames, the result might not be intuitive as paths will always be interpreted relative to /.

To Reproduce

E.g. let's imagine there is a file /tmp/test.nix that calls types.paths.toType "./derp", then the result will be /derp.

Expected behavior

For the above example, the user might reasonably assume the result to be /tmp/derp as that would correspond with way Nix treats paths.

Additional context

As there doesn't seem to be a way to capture the source file where the input string originates, it's probably better to add an assertion and only admit absolute pathnames here.

This issue was originally spotted at https://github.com/numtide/bld/pull/13/files#r1062709477

4z3 avatar Jan 09 '23 13:01 4z3