diff options
Diffstat (limited to 'src/nix-env/user-env.cc')
-rw-r--r-- | src/nix-env/user-env.cc | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc index 3bc31b9eafeb..ca27a7248107 100644 --- a/src/nix-env/user-env.cc +++ b/src/nix-env/user-env.cc @@ -33,63 +33,63 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, /* Build the components in the user environment, if they don't exist already. */ PathSet drvsToBuild; - foreach (DrvInfos::iterator, i, elems) - if (i->queryDrvPath() != "") - drvsToBuild.insert(i->queryDrvPath()); + for (auto & i : elems) + if (i.queryDrvPath() != "") + drvsToBuild.insert(i.queryDrvPath()); debug(format("building user environment dependencies")); - store->buildPaths(drvsToBuild, state.repair ? bmRepair : bmNormal); + state.store->buildPaths(drvsToBuild, state.repair ? bmRepair : bmNormal); /* Construct the whole top level derivation. */ PathSet references; Value manifest; state.mkList(manifest, elems.size()); unsigned int n = 0; - foreach (DrvInfos::iterator, i, elems) { + for (auto & i : elems) { /* Create a pseudo-derivation containing the name, system, output paths, and optionally the derivation path, as well as the meta attributes. */ - Path drvPath = keepDerivations ? i->queryDrvPath() : ""; + Path drvPath = keepDerivations ? i.queryDrvPath() : ""; Value & v(*state.allocValue()); - manifest.list.elems[n++] = &v; + manifest.listElems()[n++] = &v; state.mkAttrs(v, 16); mkString(*state.allocAttr(v, state.sType), "derivation"); - mkString(*state.allocAttr(v, state.sName), i->name); - if (!i->system.empty()) - mkString(*state.allocAttr(v, state.sSystem), i->system); - mkString(*state.allocAttr(v, state.sOutPath), i->queryOutPath()); + mkString(*state.allocAttr(v, state.sName), i.name); + if (!i.system.empty()) + mkString(*state.allocAttr(v, state.sSystem), i.system); + mkString(*state.allocAttr(v, state.sOutPath), i.queryOutPath()); if (drvPath != "") - mkString(*state.allocAttr(v, state.sDrvPath), i->queryDrvPath()); + mkString(*state.allocAttr(v, state.sDrvPath), i.queryDrvPath()); - // Copy each output. - DrvInfo::Outputs outputs = i->queryOutputs(); + // Copy each output meant for installation. + DrvInfo::Outputs outputs = i.queryOutputs(true); Value & vOutputs = *state.allocAttr(v, state.sOutputs); state.mkList(vOutputs, outputs.size()); unsigned int m = 0; - foreach (DrvInfo::Outputs::iterator, j, outputs) { - mkString(*(vOutputs.list.elems[m++] = state.allocValue()), j->first); - Value & vOutputs = *state.allocAttr(v, state.symbols.create(j->first)); + for (auto & j : outputs) { + mkString(*(vOutputs.listElems()[m++] = state.allocValue()), j.first); + Value & vOutputs = *state.allocAttr(v, state.symbols.create(j.first)); state.mkAttrs(vOutputs, 2); - mkString(*state.allocAttr(vOutputs, state.sOutPath), j->second); + mkString(*state.allocAttr(vOutputs, state.sOutPath), j.second); /* This is only necessary when installing store paths, e.g., `nix-env -i /nix/store/abcd...-foo'. */ - store->addTempRoot(j->second); - store->ensurePath(j->second); + state.store->addTempRoot(j.second); + state.store->ensurePath(j.second); - references.insert(j->second); + references.insert(j.second); } // Copy the meta attributes. Value & vMeta = *state.allocAttr(v, state.sMeta); state.mkAttrs(vMeta, 16); - StringSet metaNames = i->queryMetaNames(); - foreach (StringSet::iterator, j, metaNames) { - Value * v = i->queryMeta(*j); + StringSet metaNames = i.queryMetaNames(); + for (auto & j : metaNames) { + Value * v = i.queryMeta(j); if (!v) continue; - vMeta.attrs->push_back(Attr(state.symbols.create(*j), v)); + vMeta.attrs->push_back(Attr(state.symbols.create(j), v)); } vMeta.attrs->sort(); v.attrs->sort(); @@ -100,7 +100,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, /* Also write a copy of the list of user environment elements to the store; we need it for future modifications of the environment. */ - Path manifestFile = store->addTextToStore("env-manifest.nix", + Path manifestFile = state.store->addTextToStore("env-manifest.nix", (format("%1%") % manifest).str(), references); /* Get the environment builder expression. */ @@ -112,7 +112,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, Value args, topLevel; state.mkAttrs(args, 3); mkString(*state.allocAttr(args, state.symbols.create("manifest")), - manifestFile, singleton<PathSet>(manifestFile)); + manifestFile, {manifestFile}); args.attrs->push_back(Attr(state.symbols.create("derivations"), &manifest)); args.attrs->sort(); mkApp(topLevel, envBuilder, args); @@ -128,7 +128,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, /* Realise the resulting store expression. */ debug("building user environment"); - store->buildPaths(singleton<PathSet>(topLevelDrv), state.repair ? bmRepair : bmNormal); + state.store->buildPaths({topLevelDrv}, state.repair ? bmRepair : bmNormal); /* Switch the current user environment to the output path. */ PathLocks lock; @@ -141,7 +141,7 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, } debug(format("switching to new user environment")); - Path generation = createGeneration(profile, topLevelOut); + Path generation = createGeneration(state.store, profile, topLevelOut); switchLink(profile, generation); return true; |