From 1c0365bd88b7d98377ff639b5ede5f725e05663b Mon Sep 17 00:00:00 2001 From: John Ericson Date: Sun, 15 Jan 2017 16:47:53 -0500 Subject: cross-stdenv: Inline useless bindings and reindent Semantics should be unchanged --- pkgs/stdenv/adapters.nix | 108 +++++++++++++++++++++++------------------------ 1 file changed, 53 insertions(+), 55 deletions(-) (limited to 'pkgs/stdenv/adapters.nix') diff --git a/pkgs/stdenv/adapters.nix b/pkgs/stdenv/adapters.nix index 5d66db266c75..7e0eaeddd2c4 100644 --- a/pkgs/stdenv/adapters.nix +++ b/pkgs/stdenv/adapters.nix @@ -56,61 +56,59 @@ rec { # Return a modified stdenv that adds a cross compiler to the # builds. - makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv // - { mkDerivation = {name ? "", buildInputs ? [], nativeBuildInputs ? [], - propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [], - selfNativeBuildInput ? false, ...}@args: let - - # *BuildInputs exists temporarily as another name for - # *HostInputs. - - # In nixpkgs, sometimes 'null' gets in as a buildInputs element, - # and we handle that through isAttrs. - nativeBuildInputsDrvs = nativeBuildInputs; - buildInputsDrvs = buildInputs; - propagatedBuildInputsDrvs = propagatedBuildInputs; - propagatedNativeBuildInputsDrvs = propagatedNativeBuildInputs; - - # The base stdenv already knows that nativeBuildInputs and - # buildInputs should be built with the usual gcc-wrapper - # And the same for propagatedBuildInputs. - nativeDrv = stdenv.mkDerivation args; - - # Temporary expression until the cross_renaming, to handle the - # case of pkgconfig given as buildInput, but to be used as - # nativeBuildInput. - hostAsNativeDrv = drv: - builtins.unsafeDiscardStringContext drv.nativeDrv.drvPath - == builtins.unsafeDiscardStringContext drv.crossDrv.drvPath; - buildInputsNotNull = stdenv.lib.filter - (drv: builtins.isAttrs drv && drv ? nativeDrv) buildInputs; - nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull; - - in stdenv.mkDerivation (args // { - name = name + "-" + cross.config; - nativeBuildInputs = nativeBuildInputsDrvs - ++ nativeInputsFromBuildInputs - ++ [ gccCross binutilsCross ] - ++ stdenv.lib.optional selfNativeBuildInput nativeDrv - # without proper `file` command, libtool sometimes fails - # to recognize 64-bit DLLs - ++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file - ; - - # Cross-linking dynamic libraries, every buildInput should - # be propagated because ld needs the -rpath-link to find - # any library needed to link the program dynamically at - # loader time. ld(1) explains it. - buildInputs = []; - propagatedBuildInputs = propagatedBuildInputsDrvs ++ buildInputsDrvs; - propagatedNativeBuildInputs = propagatedNativeBuildInputsDrvs; - - crossConfig = cross.config; - } // args.crossAttrs or {}); - } // { - inherit gccCross binutilsCross; - ccCross = gccCross; - }; + makeStdenvCross = stdenv: cross: binutilsCross: gccCross: stdenv // { + + mkDerivation = + { name ? "", buildInputs ? [], nativeBuildInputs ? [] + , propagatedBuildInputs ? [], propagatedNativeBuildInputs ? [] + , selfNativeBuildInput ? false, ... + } @ args: + + let + # *BuildInputs exists temporarily as another name for + # *HostInputs. + + # The base stdenv already knows that nativeBuildInputs and + # buildInputs should be built with the usual gcc-wrapper + # And the same for propagatedBuildInputs. + nativeDrv = stdenv.mkDerivation args; + + # Temporary expression until the cross_renaming, to handle the + # case of pkgconfig given as buildInput, but to be used as + # nativeBuildInput. + hostAsNativeDrv = drv: + builtins.unsafeDiscardStringContext drv.nativeDrv.drvPath + == builtins.unsafeDiscardStringContext drv.crossDrv.drvPath; + buildInputsNotNull = stdenv.lib.filter + (drv: builtins.isAttrs drv && drv ? nativeDrv) buildInputs; + nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull; + in + stdenv.mkDerivation (args // { + name = name + "-" + cross.config; + nativeBuildInputs = nativeBuildInputs + ++ nativeInputsFromBuildInputs + ++ [ gccCross binutilsCross ] + ++ stdenv.lib.optional selfNativeBuildInput nativeDrv + # without proper `file` command, libtool sometimes fails + # to recognize 64-bit DLLs + ++ stdenv.lib.optional (cross.config == "x86_64-w64-mingw32") pkgs.file + ; + + # Cross-linking dynamic libraries, every buildInput should + # be propagated because ld needs the -rpath-link to find + # any library needed to link the program dynamically at + # loader time. ld(1) explains it. + buildInputs = []; + propagatedBuildInputs = propagatedBuildInputs ++ buildInputs; + propagatedNativeBuildInputs = propagatedNativeBuildInputs; + + crossConfig = cross.config; + } // args.crossAttrs or {}); + + inherit gccCross binutilsCross; + ccCross = gccCross; + + }; /* Modify a stdenv so that the specified attributes are added to -- cgit 1.4.1