Apply makeOverridable to stdenv

This removes the need for hacks like stdenv.regenerate.  It also
ensures that overrideGCC is now stackable (so ‘stdenv = useGoldLinker
clangStdenv’ works).
This commit is contained in:
Eelco Dolstra 2014-02-04 17:18:38 +01:00
parent 7703f04b75
commit c3d84d15ce
4 changed files with 141 additions and 160 deletions

View file

@ -8,20 +8,14 @@ rec {
# Override the compiler in stdenv for specific packages.
overrideGCC = stdenv: gcc: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args // { NIX_GCC = gcc; });
inherit gcc;
};
overrideGCC = stdenv: gcc: stdenv.override { inherit gcc; };
# Add some arbitrary packages to buildInputs for specific packages.
# Used to override packages in stdenv like Make. Should not be used
# for other dependencies.
overrideInStdenv = stdenv: pkgs: stdenv //
{ mkDerivation = args: stdenv.mkDerivation (args //
{ buildInputs = args.buildInputs or [] ++ pkgs; }
);
};
overrideInStdenv = stdenv: pkgs:
stdenv.override (prev: { extraBuildInputs = prev.extraBuildInputs or [] ++ pkgs; });
# Override the setup script of stdenv. Useful for testing new
@ -32,7 +26,7 @@ rec {
# randomPkg = import ../bla { ...
# stdenv = overrideSetup stdenv ../stdenv/generic/setup-latest.sh;
# };
overrideSetup = stdenv: setup: stdenv.regenerate setup;
overrideSetup = stdenv: setupScript: stdenv.override { inherit setupScript; };
# Return a modified stdenv that uses dietlibc to create small

View file

@ -1,9 +1,15 @@
let lib = import ../../../lib; in lib.makeOverridable (
{ system, name ? "stdenv", preHook ? "", initialPath, gcc, shell
, extraAttrs ? {}, overrides ? (pkgs: {}), config
, # The `fetchurl' to use for downloading curl and its dependencies
# (see all-packages.nix).
fetchurlBoot
, setupScript ? ./setup.sh
, extraBuildInputs ? []
}:
if ! builtins ? langVersion then
@ -14,16 +20,12 @@ else
let
lib = import ../../../lib;
allowUnfree = config.allowUnfree or true && builtins.getEnv "HYDRA_DISALLOW_UNFREE" != "1";
allowBroken = builtins.getEnv "NIXPKGS_ALLOW_BROKEN" == "1";
unsafeGetAttrPos = builtins.unsafeGetAttrPos or (n: as: null);
stdenvGenerator = setupScript: rec {
# The stdenv that we are producing.
result =
@ -85,12 +87,10 @@ let
userHook = config.stdenv.userHook or null;
# Inputs built by the cross compiler.
buildInputs = lib.optionals (crossConfig != null) buildInputs;
propagatedBuildInputs = lib.optionals (crossConfig != null)
propagatedBuildInputs;
buildInputs = lib.optionals (crossConfig != null) buildInputs ++ extraBuildInputs;
propagatedBuildInputs = lib.optionals (crossConfig != null) propagatedBuildInputs;
# Inputs built by the usual native compiler.
nativeBuildInputs = nativeBuildInputs ++ lib.optionals
(crossConfig == null) buildInputs;
nativeBuildInputs = nativeBuildInputs ++ lib.optionals (crossConfig == null) buildInputs;
propagatedNativeBuildInputs = propagatedNativeBuildInputs ++
lib.optionals (crossConfig == null) propagatedBuildInputs;
}))) (
@ -156,11 +156,6 @@ let
|| result.system == "armv6l-linux"
|| result.system == "armv7l-linux";
# Utility function: allow stdenv to be easily regenerated with
# a different setup script. (See all-packages.nix for an
# example.)
regenerate = stdenvGenerator;
# For convenience, bring in the library functions in lib/ so
# packages don't have to do that themselves.
inherit lib;
@ -176,7 +171,4 @@ let
# like curl = if stdenv ? curl then stdenv.curl else ...).
// extraAttrs;
}.result;
in stdenvGenerator ./setup.sh
in result)

View file

@ -782,12 +782,7 @@ let
despotify = callPackage ../development/libraries/despotify { };
dev86 = callPackage ../development/compilers/dev86 {
/* Using GNU Make 3.82 leads to this:
make[4]: *** No rule to make target `__ldivmod.o)'
So use 3.81. */
stdenv = overrideInStdenv stdenv [gnumake381];
};
dev86 = callPackage ../development/compilers/dev86 { };
dnsmasq = callPackage ../tools/networking/dnsmasq { };