Skip to content

Commit 348526e

Browse files
committed
nix develop: Use store->getFSAccessor()
1 parent c8aeadb commit 348526e

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/nix/develop.cc

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -300,12 +300,13 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
300300
bmNormal,
301301
evalStore);
302302

303+
// `get-env.sh` will write its JSON output to an arbitrary output
304+
// path, so return the first non-empty output path.
303305
for (auto & [_0, optPath] : evalStore->queryPartialDerivationOutputMap(shellDrvPath)) {
304306
assert(optPath);
305307
auto & outPath = *optPath;
306-
assert(store->isValidPath(outPath));
307-
auto outPathS = store->toRealPath(outPath);
308-
if (lstat(outPathS).st_size)
308+
auto st = store->getFSAccessor()->lstat(CanonPath(outPath.to_string()));
309+
if (st.fileSize.value_or(0))
309310
return outPath;
310311
}
311312

@@ -495,17 +496,15 @@ struct Common : InstallableCommand, MixProfile
495496
}
496497
}
497498

498-
std::pair<BuildEnvironment, std::string> getBuildEnvironment(ref<Store> store, ref<Installable> installable)
499+
std::pair<BuildEnvironment, StorePath> getBuildEnvironment(ref<Store> store, ref<Installable> installable)
499500
{
500501
auto shellOutPath = getShellOutPath(store, installable);
501502

502-
auto strPath = store->printStorePath(shellOutPath);
503-
504503
updateProfile(shellOutPath);
505504

506-
debug("reading environment file '%s'", strPath);
505+
debug("reading environment file '%s'", store->printStorePath(shellOutPath));
507506

508-
return {BuildEnvironment::parseJSON(readFile(store->toRealPath(shellOutPath))), strPath};
507+
return {BuildEnvironment::parseJSON(store->getFSAccessor()->readFile(shellOutPath.to_string())), shellOutPath};
509508
}
510509
};
511510

@@ -634,7 +633,7 @@ struct CmdDevelop : Common, MixEnvironment
634633

635634
setEnviron();
636635
// prevent garbage collection until shell exits
637-
setEnv("NIX_GCROOT", gcroot.c_str());
636+
setEnv("NIX_GCROOT", store->printStorePath(gcroot).c_str());
638637

639638
Path shell = "bash";
640639

0 commit comments

Comments
 (0)