Skip to content

Commit bf86b93

Browse files
authored
Merge pull request #10391 from edolstra/home-symlink
Handle the case where a parent of ~/.nix-defexpr is a symlink
2 parents 36d92dc + 09551fa commit bf86b93

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/nix-env/nix-env.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ static void getAllExprs(EvalState & state,
109109
const SourcePath & path, StringSet & seen, BindingsBuilder & attrs)
110110
{
111111
StringSet namesSorted;
112-
for (auto & [name, _] : path.readDirectory()) namesSorted.insert(name);
112+
for (auto & [name, _] : path.resolveSymlinks().readDirectory()) namesSorted.insert(name);
113113

114114
for (auto & i : namesSorted) {
115115
/* Ignore the manifest.nix used by profiles. This is

tests/functional/user-envs.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,3 +189,9 @@ nix-env --set $outPath10
189189
[ "$(nix-store -q --resolve $profiles/test)" = $outPath10 ]
190190
nix-env --set $drvPath10
191191
[ "$(nix-store -q --resolve $profiles/test)" = $outPath10 ]
192+
193+
# Test the case where $HOME contains a symlink.
194+
mkdir -p $TEST_ROOT/real-home/alice/.nix-defexpr/channels
195+
ln -sfn $TEST_ROOT/real-home $TEST_ROOT/home
196+
ln -sfn $(pwd)/user-envs.nix $TEST_ROOT/home/alice/.nix-defexpr/channels/foo
197+
HOME=$TEST_ROOT/home/alice nix-env -i foo-0.1

0 commit comments

Comments
 (0)