From 734d7df2351ac1a10774e665447c5cdc286fc16e Mon Sep 17 00:00:00 2001 From: Artturin Date: Wed, 7 Dec 2022 00:08:33 +0200 Subject: [PATCH] allow derivation attributes in env derivations can be coerced to their output paths --- .../build-support/bintools-wrapper/default.nix | 18 +++++++++--------- pkgs/build-support/cc-wrapper/default.nix | 15 +++++++++------ pkgs/stdenv/generic/make-derivation.nix | 4 ++-- 3 files changed, 20 insertions(+), 17 deletions(-) diff --git a/pkgs/build-support/bintools-wrapper/default.nix b/pkgs/build-support/bintools-wrapper/default.nix index ea925e90fa47..d41eaabe51a1 100644 --- a/pkgs/build-support/bintools-wrapper/default.nix +++ b/pkgs/build-support/bintools-wrapper/default.nix @@ -103,15 +103,12 @@ stdenv.mkDerivation { preferLocalBuild = true; - inherit bintools_bin libc_bin libc_dev libc_lib coreutils_bin; - shell = getBin shell + shell.shellPath or ""; - gnugrep_bin = if nativeTools then "" else gnugrep; - - inherit targetPrefix suffixSalt; + inherit bintools_bin libc_bin libc_dev libc_lib; outputs = [ "out" ] ++ optionals propagateDoc ([ "man" ] ++ optional (bintools ? info) "info"); passthru = { + inherit targetPrefix suffixSalt; inherit bintools libc nativeTools nativeLibc nativePrefix; emacsBufferSetup = pkgs: '' @@ -366,10 +363,13 @@ stdenv.mkDerivation { ## + extraBuildCommands; - inherit dynamicLinker; - - # for substitution in utils.bash - expandResponseParams = "${expand-response-params}/bin/expand-response-params"; + env = { + # for substitution in utils.bash + expandResponseParams = "${expand-response-params}/bin/expand-response-params"; + shell = getBin shell + shell.shellPath or ""; + gnugrep_bin = if nativeTools then "" else gnugrep; + inherit dynamicLinker suffixSalt coreutils_bin; + }; meta = let bintools_ = if bintools != null then bintools else {}; in diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index a59505d08258..851b36fc2241 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -131,16 +131,14 @@ stdenv.mkDerivation { preferLocalBuild = true; - inherit cc libc_bin libc_dev libc_lib bintools coreutils_bin; - shell = getBin shell + shell.shellPath or ""; - gnugrep_bin = if nativeTools then "" else gnugrep; + inherit cc libc_bin libc_dev libc_lib; - inherit targetPrefix suffixSalt; inherit darwinPlatformForCC darwinMinVersion darwinMinVersionVariable; outputs = [ "out" ] ++ optionals propagateDoc [ "man" "info" ]; passthru = { + inherit targetPrefix suffixSalt; # "cc" is the generic name for a C compiler, but there is no one for package # providing the linker and related tools. The two we use now are GNU # Binutils, and Apple's "cctools"; "bintools" as an attempt to find an @@ -538,8 +536,13 @@ stdenv.mkDerivation { nixSupport); - # for substitution in utils.bash - expandResponseParams = "${expand-response-params}/bin/expand-response-params"; + env = { + # for substitution in utils.bash + expandResponseParams = "${expand-response-params}/bin/expand-response-params"; + shell = getBin shell + shell.shellPath or ""; + gnugrep_bin = if nativeTools then "" else gnugrep; + inherit suffixSalt coreutils_bin bintools; + }; meta = let cc_ = if cc != null then cc else {}; in diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix index 2f02bc7d1d78..12aa25ac307c 100644 --- a/pkgs/stdenv/generic/make-derivation.nix +++ b/pkgs/stdenv/generic/make-derivation.nix @@ -488,8 +488,8 @@ else let assert lib.assertMsg (overlappingNames == [ ]) "The ‘env’ attribute set cannot contain any attributes passed to derivation. The following attributes are overlapping: ${lib.concatStringsSep ", " overlappingNames}"; lib.mapAttrs - (n: v: assert lib.assertMsg (lib.isString v || lib.isBool v || lib.isInt v) - "The ‘env’ attribute set can only contain string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v) + (n: v: assert lib.assertMsg (lib.isString v || lib.isBool v || lib.isInt v || lib.isDerivation v) + "The ‘env’ attribute set can only contain derivation, string, boolean or integer attributes. The ‘${n}’ attribute is of type ${builtins.typeOf v}."; v) env; in