Skip to content

Commit 6a761c1

Browse files
authored
Merge pull request #13296 from xokdvium/empty-accessor-prefix
Clear `displayPrefix` in `makeEmptySourceAccessor`
2 parents e72f19e + fba1bb0 commit 6a761c1

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

src/libutil/memory-source-accessor.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ void MemorySink::createSymlink(const CanonPath & path, const std::string & targe
187187
ref<SourceAccessor> makeEmptySourceAccessor()
188188
{
189189
static auto empty = make_ref<MemorySourceAccessor>().cast<SourceAccessor>();
190+
/* Don't forget to clear the display prefix, as the default constructed
191+
SourceAccessor has the «unknown» prefix. Since this accessor is supposed
192+
to mimic an empty root directory the prefix needs to be empty. */
193+
empty->setPathDisplay("");
190194
return empty;
191195
}
192196

tests/functional/pure-eval.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,15 @@ rm -rf $TEST_ROOT/eval-out
3434
(! nix eval --store dummy:// --write-to $TEST_ROOT/eval-out --expr '{ "." = "bla"; }')
3535

3636
(! nix eval --expr '~/foo')
37+
38+
expectStderr 0 nix eval --expr "/some/absolute/path" \
39+
| grepQuiet "/some/absolute/path"
40+
41+
expectStderr 0 nix eval --expr "/some/absolute/path" --impure \
42+
| grepQuiet "/some/absolute/path"
43+
44+
expectStderr 0 nix eval --expr "some/relative/path" \
45+
| grepQuiet "$PWD/some/relative/path"
46+
47+
expectStderr 0 nix eval --expr "some/relative/path" --impure \
48+
| grepQuiet "$PWD/some/relative/path"

0 commit comments

Comments
 (0)