@@ -228,11 +228,13 @@ const static std::string getEnvSh =
228
228
#include " get-env.sh.gen.hh"
229
229
;
230
230
231
- /* Given an existing derivation, return the shell environment as
232
- initialised by stdenv's setup script. We do this by building a
233
- modified derivation with the same dependencies and nearly the same
234
- initial environment variables, that just writes the resulting
235
- environment to a file and exits. */
231
+ /* *
232
+ * Given an existing derivation, return the shell environment as
233
+ * initialised by stdenv's setup script. We do this by building a
234
+ * modified derivation with the same dependencies and nearly the same
235
+ * initial environment variables, that just writes the resulting
236
+ * environment to a file and exits.
237
+ */
236
238
static StorePath getDerivationEnvironment (ref<Store> store, ref<Store> evalStore, const StorePath & drvPath)
237
239
{
238
240
auto drv = evalStore->derivationFromPath (drvPath);
@@ -298,12 +300,13 @@ static StorePath getDerivationEnvironment(ref<Store> store, ref<Store> evalStore
298
300
bmNormal,
299
301
evalStore);
300
302
303
+ // `get-env.sh` will write its JSON output to an arbitrary output
304
+ // path, so return the first non-empty output path.
301
305
for (auto & [_0, optPath] : evalStore->queryPartialDerivationOutputMap (shellDrvPath)) {
302
306
assert (optPath);
303
307
auto & outPath = *optPath;
304
- assert (store->isValidPath (outPath));
305
- auto outPathS = store->toRealPath (outPath);
306
- if (lstat (outPathS).st_size )
308
+ auto st = store->getFSAccessor ()->lstat (CanonPath (outPath.to_string ()));
309
+ if (st.fileSize .value_or (0 ))
307
310
return outPath;
308
311
}
309
312
@@ -493,17 +496,15 @@ struct Common : InstallableCommand, MixProfile
493
496
}
494
497
}
495
498
496
- std::pair<BuildEnvironment, std::string > getBuildEnvironment (ref<Store> store, ref<Installable> installable)
499
+ std::pair<BuildEnvironment, StorePath > getBuildEnvironment (ref<Store> store, ref<Installable> installable)
497
500
{
498
501
auto shellOutPath = getShellOutPath (store, installable);
499
502
500
- auto strPath = store->printStorePath (shellOutPath);
501
-
502
503
updateProfile (shellOutPath);
503
504
504
- debug (" reading environment file '%s'" , strPath );
505
+ debug (" reading environment file '%s'" , store-> printStorePath (shellOutPath) );
505
506
506
- return {BuildEnvironment::parseJSON (readFile ( store->toRealPath ( shellOutPath))), strPath };
507
+ return {BuildEnvironment::parseJSON (store->getFSAccessor ()-> readFile ( shellOutPath. to_string ( ))), shellOutPath };
507
508
}
508
509
};
509
510
@@ -632,7 +633,7 @@ struct CmdDevelop : Common, MixEnvironment
632
633
633
634
setEnviron ();
634
635
// prevent garbage collection until shell exits
635
- setEnv (" NIX_GCROOT" , gcroot.c_str ());
636
+ setEnv (" NIX_GCROOT" , store-> printStorePath ( gcroot) .c_str ());
636
637
637
638
Path shell = " bash" ;
638
639
0 commit comments