nix develop: Support derivations with multiple outputs

This commit is contained in:
Eelco Dolstra 2020-07-06 18:34:58 +02:00
parent cd8eb8a7d1
commit 68f524d717
3 changed files with 12 additions and 0 deletions

View file

@ -130,7 +130,9 @@ StorePath getDerivationEnvironment(ref<Store> store, const StorePath & drvPath)
drvName += "-env"; drvName += "-env";
for (auto & output : drv.outputs) for (auto & output : drv.outputs)
drv.env.erase(output.first); drv.env.erase(output.first);
drv.outputs = {{"out", DerivationOutput { .path = StorePath::dummy }}};
drv.env["out"] = ""; drv.env["out"] = "";
drv.env["_outputs_saved"] = drv.env["outputs"];
drv.env["outputs"] = "out"; drv.env["outputs"] = "out";
drv.inputSrcs.insert(std::move(getEnvShPath)); drv.inputSrcs.insert(std::move(getEnvShPath));
Hash h = hashDerivationModulo(*store, drv, true); Hash h = hashDerivationModulo(*store, drv, true);

View file

@ -1,9 +1,18 @@
set -e set -e
if [ -e .attrs.sh ]; then source .attrs.sh; fi if [ -e .attrs.sh ]; then source .attrs.sh; fi
outputs=$_outputs_saved
for __output in $_outputs_saved; do
declare "$__output"="$out"
done
unset _outputs_saved __output
export IN_NIX_SHELL=impure export IN_NIX_SHELL=impure
export dontAddDisableDepTrack=1 export dontAddDisableDepTrack=1
if [[ -n $stdenv ]]; then if [[ -n $stdenv ]]; then
source $stdenv/setup source $stdenv/setup
fi fi
export > $out export > $out
set >> $out set >> $out

View file

@ -24,6 +24,7 @@ let pkgs = rec {
VAR_FROM_NIX = "bar"; VAR_FROM_NIX = "bar";
TEST_inNixShell = if inNixShell then "true" else "false"; TEST_inNixShell = if inNixShell then "true" else "false";
inherit stdenv; inherit stdenv;
outputs = ["dev" "out"];
}; };
# Used by nix-shell -p # Used by nix-shell -p