From 5ad89398d12bf8bc83426036dedc2c601ff8f795 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 4 Dec 2012 14:20:36 +0100 Subject: nix-env: Install all outputs of a derivation If you explicitly install a package, presumably you want all of it. So symlink all outputs in the user environment. --- src/nix-env/user-env.cc | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/nix-env/user-env.cc') diff --git a/src/nix-env/user-env.cc b/src/nix-env/user-env.cc index 0a50493fd153..727c4bd44d69 100644 --- a/src/nix-env/user-env.cc +++ b/src/nix-env/user-env.cc @@ -54,21 +54,42 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, unsigned int n = 0; foreach (DrvInfos::iterator, i, elems) { /* Create a pseudo-derivation containing the name, system, - output path, and optionally the derivation path, as well as - the meta attributes. */ + output paths, and optionally the derivation path, as well + as the meta attributes. */ Path drvPath = keepDerivations ? i->queryDrvPath(state) : ""; Value & v(*state.allocValue()); manifest.list.elems[n++] = &v; - state.mkAttrs(v, 8); + state.mkAttrs(v, 16); mkString(*state.allocAttr(v, state.sType), "derivation"); mkString(*state.allocAttr(v, state.sName), i->name); - mkString(*state.allocAttr(v, state.sSystem), i->system); + if (!i->system.empty()) + mkString(*state.allocAttr(v, state.sSystem), i->system); mkString(*state.allocAttr(v, state.sOutPath), i->queryOutPath(state)); if (drvPath != "") mkString(*state.allocAttr(v, state.sDrvPath), i->queryDrvPath(state)); + // Copy each output. + DrvInfo::Outputs outputs = i->queryOutputs(state); + 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)); + state.mkAttrs(vOutputs, 2); + 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); + + references.insert(j->second); + } + + // Copy the meta attributes. Value & vMeta = *state.allocAttr(v, state.sMeta); state.mkAttrs(vMeta, 16); @@ -95,12 +116,6 @@ bool createUserEnv(EvalState & state, DrvInfos & elems, vMeta.attrs->sort(); v.attrs->sort(); - /* This is only necessary when installing store paths, e.g., - `nix-env -i /nix/store/abcd...-foo'. */ - store->addTempRoot(i->queryOutPath(state)); - store->ensurePath(i->queryOutPath(state)); - - references.insert(i->queryOutPath(state)); if (drvPath != "") references.insert(drvPath); } -- cgit 1.4.1