Missing outputs

Basic question. How do I specify the outputs I want for a nix-shell environment?

This is my default.nix

with import<nixpkgs> {};
stdenv.mkDerivation rec {
  name = "env";

  outputs = ["out" "bin" "lib" "dev"];

  dependencies = [

  env = buildEnv {
    name = name;
    paths = dependencies;


The dev output is missing from my environment.

1 Like

I know it’s an old post, I just arrived here looking for documentation on that.

I think that to create the output, you just need to do that in the installPhase:

mkdir -p $out $bin $lib $dev

To be confirmed.

Having outputs for nix-shell environment is pretty much meaningless – nix-shell does not build the outputs, it just sets environment variables from the derivation and then runs $stdenv/setup. So adding outputs attribute would just populate the output variables with output paths as described in the manual. But those paths would not exist in the Nix store unless you previously built the derivation used for the shell.

installPhase would not be invoked by nix-shell either.

It is not clear what the opening post is actually trying to achieve. mkDerivation does not know dependencies and, at the time, did not know env (which now contains variables that should be passed to the builder as environment variables even when __structuredAttrs are enabled), so those would have just been passed to the executed shell as two environment variables – not very practical shell.

If you want to specify what outputs of derivations listed in paths to link to the env symlink tree, you should use the extraOutputsToInstall argument of buildEnv:

1 Like