Unverified Commit fe2315d7 authored by 0xda157's avatar 0xda157
Browse files

mkShell: use extendMkDerivation

parent 44088fa1
Loading
Loading
Loading
Loading
+48 −57
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  buildEnv,
}:

# A special kind of derivation that is only meant to be consumed by the
# nix-shell.
lib.extendMkDerivation {
  constructDrv = stdenv.mkDerivation;

  excludeDrvArgNames = [
    "packages"
    "inputsFrom"
  ];

  extendDrvArgs =
    _finalAttrs:
    {
      name ? "nix-shell",
      # a list of packages to add to the shell environment
      packages ? [ ],
      # propagate all the inputs from the given derivations
      inputsFrom ? [ ],
  buildInputs ? [ ],
  nativeBuildInputs ? [ ],
  propagatedBuildInputs ? [ ],
  propagatedNativeBuildInputs ? [ ],
      ...
    }@attrs:
    let
@@ -28,20 +32,7 @@ let
          # 3. filter out of the result everything that's in `inputsFrom` itself
          # this leaves actual dependencies of the derivations in `inputsFrom`, but never the derivations themselves
          (lib.subtractLists inputsFrom (lib.flatten (lib.catAttrs name inputsFrom)));

  rest = removeAttrs attrs [
    "name"
    "packages"
    "inputsFrom"
    "buildInputs"
    "nativeBuildInputs"
    "propagatedBuildInputs"
    "propagatedNativeBuildInputs"
    "shellHook"
  ];
    in

stdenv.mkDerivation (
    {
      inherit name;

@@ -54,9 +45,10 @@ stdenv.mkDerivation (
        lib.catAttrs "shellHook" (lib.reverseList inputsFrom ++ [ attrs ])
      );

    phases = [ "buildPhase" ];
      phases = attrs.phases or [ "buildPhase" ];

    buildPhase = ''
      buildPhase =
        attrs.buildPhase or ''
          { echo "------------------------------------------------------------";
            echo " WARNING: the existence of this path is not guaranteed.";
            echo " It is an internal implementation detail for pkgs.mkShell.";
@@ -67,7 +59,6 @@ stdenv.mkDerivation (
          } >> "$out"
        '';

    preferLocalBuild = true;
      preferLocalBuild = attrs.preferLocalBuild or true;
    };
}
  // rest
)