mirror of
https://github.com/NixOS/nix.git
synced 2025-11-09 20:16:03 +01:00
libutil: Create empty directory at the root for makeEmptySourceAccessor
This is my SNAFU. Accidentally broken in 02c9ac445f.
There's very dubious behavior for 'builtins.readDir /.':
{
outputs =
{ ... }:
{
lib.a = builtins.readDir /.;
};
}
nix eval /tmp/test-flake#lib.a
Starting from 2.27 this now returns an empty set. This really isn't supposed
to happen, but this change in the semantics of makeEmptySourceAccessor accidentally
changed the behavior of this.
This commit is contained in:
parent
8a968c599d
commit
1830f5f967
1 changed files with 10 additions and 5 deletions
|
|
@ -208,11 +208,16 @@ void MemorySink::createSymlink(const CanonPath & path, const std::string & targe
|
|||
|
||||
ref<SourceAccessor> makeEmptySourceAccessor()
|
||||
{
|
||||
static auto empty = make_ref<MemorySourceAccessor>().cast<SourceAccessor>();
|
||||
/* Don't forget to clear the display prefix, as the default constructed
|
||||
SourceAccessor has the «unknown» prefix. Since this accessor is supposed
|
||||
to mimic an empty root directory the prefix needs to be empty. */
|
||||
empty->setPathDisplay("");
|
||||
static auto empty = []() {
|
||||
auto empty = make_ref<MemorySourceAccessor>();
|
||||
MemorySink sink{*empty};
|
||||
sink.createDirectory(CanonPath::root);
|
||||
/* Don't forget to clear the display prefix, as the default constructed
|
||||
SourceAccessor has the «unknown» prefix. Since this accessor is supposed
|
||||
to mimic an empty root directory the prefix needs to be empty. */
|
||||
empty->setPathDisplay("");
|
||||
return empty.cast<SourceAccessor>();
|
||||
}();
|
||||
return empty;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue