summary refs log tree commit diff
path: root/pkgs/stdenv/generic/make-derivation.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2017-07-12 19:00:19 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-07-13 19:05:36 -0400
commite826a6a24774045b7d7d4e9814d8356278b84568 (patch)
tree24e3f6f69d1576a2429f896f917ee7f07c532ef7 /pkgs/stdenv/generic/make-derivation.nix
parent30a14204149c8fb43001c4f2188e8e655a9a389a (diff)
downloadnixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar.gz
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar.bz2
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar.lz
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar.xz
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.tar.zst
nixlib-e826a6a24774045b7d7d4e9814d8356278b84568.zip
stdenv: Move some logic from cross adapter to stdenv proper
Eventually the adapter will be removed.  Moved is

 - Name suffix from hostPlatform

 - configurePlatforms

   To not cause more breakage, the default is currently [], but
   eventually it will be [ "build" "host" ], as the cross adapter makes
   it today.
Diffstat (limited to 'pkgs/stdenv/generic/make-derivation.nix')
-rw-r--r--pkgs/stdenv/generic/make-derivation.nix23
1 files changed, 22 insertions, 1 deletions
diff --git a/pkgs/stdenv/generic/make-derivation.nix b/pkgs/stdenv/generic/make-derivation.nix
index 05221e2f3c10..1486b11f7016 100644
--- a/pkgs/stdenv/generic/make-derivation.nix
+++ b/pkgs/stdenv/generic/make-derivation.nix
@@ -12,12 +12,22 @@ rec {
   # * https://nixos.org/nix/manual/#ssec-derivation
   #   Explanation about derivations in general
   mkDerivation =
-    { nativeBuildInputs ? []
+    { name ? ""
+
+    , nativeBuildInputs ? []
     , buildInputs ? []
 
     , propagatedNativeBuildInputs ? []
     , propagatedBuildInputs ? []
 
+    , configureFlags ? []
+    , # Target is not included by default because most programs don't care.
+      # Including it then would cause needless mass rebuilds.
+      #
+      # TODO(@Ericson2314): Make [ "build" "host" ] always the default.
+      configurePlatforms ? lib.optionals
+        (stdenv.hostPlatform != stdenv.buildPlatform)
+        [ "build" "host" ]
     , crossConfig ? null
     , meta ? {}
     , passthru ? {}
@@ -72,6 +82,9 @@ rec {
             lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (lib.concatLists propagatedDependencies'));
         in
         {
+          name = name + lib.optionalString
+            (stdenv.hostPlatform != stdenv.buildPlatform)
+            stdenv.hostPlatform.config;
           builder = attrs.realBuilder or stdenv.shell;
           args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
           inherit stdenv;
@@ -84,6 +97,14 @@ rec {
 
           propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
           propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
+
+          # This parameter is sometimes a string and sometimes a list, yuck
+          configureFlags = let inherit (lib) optional elem; in
+            (if lib.isString configureFlags then [configureFlags] else configureFlags)
+            ++ optional (elem "build"  configurePlatforms) "--build=${stdenv.buildPlatform.config}"
+            ++ optional (elem "host"   configurePlatforms) "--host=${stdenv.hostPlatform.config}"
+            ++ optional (elem "target" configurePlatforms) "--target=${stdenv.targetPlatform.config}";
+
         } // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
           # TODO: remove lib.unique once nix has a list canonicalization primitive
           __sandboxProfile =