Something went wrong. Try again.
What happens if I push all of nixpkgs
Something went wrong. Try again.
2.8 kB · 103 lines
Nix
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104{ lib, stdenv, buildEnv, devShellTools,}:
# A special kind of derivation that is only meant to be consumed by the# nix-shell.{ 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 ? [ ], passthru ? { }, ...}@attrs:let mergeInputs = name: (attrs.${name} or [ ]) ++ # 1. get all `{build,nativeBuild,...}Inputs` from the elements of `inputsFrom` # 2. since that is a list of lists, `flatten` that into a regular list # 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 = builtins.removeAttrs attrs [ "name" "packages" "inputsFrom" "buildInputs" "nativeBuildInputs" "propagatedBuildInputs" "propagatedNativeBuildInputs" "shellHook" ];in
stdenv.mkDerivation ( finalAttrs: { inherit name;
buildInputs = mergeInputs "buildInputs"; nativeBuildInputs = packages ++ (mergeInputs "nativeBuildInputs"); propagatedBuildInputs = mergeInputs "propagatedBuildInputs"; propagatedNativeBuildInputs = mergeInputs "propagatedNativeBuildInputs";
shellHook = lib.concatStringsSep "\n" ( lib.catAttrs "shellHook" (lib.reverseList inputsFrom ++ [ attrs ]) );
phases = [ "buildPhase" ];
buildPhase = '' { echo "------------------------------------------------------------"; echo " WARNING: the existence of this path is not guaranteed."; echo " It is an internal implementation detail for pkgs.mkShell."; echo "------------------------------------------------------------"; echo; # Record all build inputs as runtime dependencies export; } >> "$out" '';
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)