diff --git a/pkgs/build-support/mkshell/default.nix b/pkgs/build-support/mkshell/default.nix index ad34882b3891..9ce5a86d02b3 100644 --- a/pkgs/build-support/mkshell/default.nix +++ b/pkgs/build-support/mkshell/default.nix @@ -2,6 +2,7 @@ lib, stdenv, buildEnv, + devShellTools, }: # A special kind of derivation that is only meant to be consumed by the @@ -16,6 +17,7 @@ nativeBuildInputs ? [ ], propagatedBuildInputs ? [ ], propagatedNativeBuildInputs ? [ ], + passthru ? { }, ... }@attrs: let @@ -42,6 +44,7 @@ let in stdenv.mkDerivation ( + finalAttrs: { inherit name; @@ -68,6 +71,33 @@ stdenv.mkDerivation ( ''; preferLocalBuild = true; + + passthru = { + devShell = + let + inherit (finalAttrs.finalPackage) drvAttrs; + in + devShellTools.buildShellEnv { + inherit drvAttrs; + + # The default prefix is "build shell", but this shell is not derived + # directly from a derivation, so we set a more generic title. + promptPrefix = "nix"; + + # Change the default name + promptName = + if + # name was passed originally + attrs ? name + # or with overrideAttrs + || drvAttrs.name != "nix-shell" + then + null + else + "mkShell"; + }; + } + // passthru; } // rest )