mkShell: Control devShell and override prompt

This commit is contained in:
Robert Hensing
2025-07-21 23:45:03 +02:00
parent fd0b01320a
commit ce7fbda708

View File

@@ -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
)