mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 15:26:17 +02:00
PosixSourceAccessor: Support roots that are not directories
We have to support this for `fetchTree { type = "file" }` (and probably other types of trees that can have a non-directory at the root, like NARs).
This commit is contained in:
parent
b00f412f81
commit
930b9c8269
2 changed files with 6 additions and 0 deletions
|
@ -30,6 +30,11 @@ std::filesystem::path PosixSourceAccessor::makeAbsPath(const CanonPath & path)
|
|||
{
|
||||
return root.empty()
|
||||
? (std::filesystem::path { path.abs() })
|
||||
: path.isRoot()
|
||||
? /* Don't append a slash for the root of the accessor, since
|
||||
it can be a non-directory (e.g. in the case of `fetchTree
|
||||
{ type = "file" }`). */
|
||||
root
|
||||
: root / path.rel();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ test_fetch_file () {
|
|||
tree = builtins.fetchTree { type = "file"; url = "file://$PWD/test_input"; };
|
||||
in
|
||||
assert (tree.narHash == "$input_hash");
|
||||
assert builtins.readFile tree == "foo\n";
|
||||
tree
|
||||
EOF
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue