summary refs log tree commit diff
path: root/pkgs/top-level/splice.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2017-06-02 12:22:36 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2017-12-30 22:04:20 -0500
commitbb18a3b5730ec1d29f4dc3a070dc753b0f9690bb (patch)
tree50a11f8baca40208b0afc2673809c3dea6b91040 /pkgs/top-level/splice.nix
parent281fb9c222bc457e0f8b30f30453c2d89f96904b (diff)
downloadnixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar.gz
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar.bz2
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar.lz
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar.xz
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.tar.zst
nixpkgs-bb18a3b5730ec1d29f4dc3a070dc753b0f9690bb.zip
top-level: Splice in more package sets for new types of deps
This is done in preparation for the next commit where, among other
changes, I add support for the new `dep*` attributes.
Diffstat (limited to 'pkgs/top-level/splice.nix')
-rw-r--r--pkgs/top-level/splice.nix69
1 files changed, 53 insertions, 16 deletions
diff --git a/pkgs/top-level/splice.nix b/pkgs/top-level/splice.nix
index ea81b110080..1fde08d1d48 100644
--- a/pkgs/top-level/splice.nix
+++ b/pkgs/top-level/splice.nix
@@ -24,25 +24,52 @@
 lib: pkgs: actuallySplice:
 
 let
-  defaultBuildScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
+  defaultBuildBuildScope = pkgs.buildPackages.buildPackages // pkgs.buildPackages.buildPackages.xorg;
+  defaultBuildHostScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
+  defaultBuildTargetScope =
+    if pkgs.targetPlatform == pkgs.hostPlatform
+    then defaultBuildHostScope
+    else assert pkgs.hostPlatform == pkgs.buildPlatform; defaultHostTargetScope;
+  defaultHostHostScope = {}; # unimplemented
   # TODO(@Ericson2314): we shouldn't preclude run-time fetching by removing
   # these attributes. We should have a more general solution for selecting
   # whether `nativeDrv` or `crossDrv` is the default in `defaultScope`.
   pkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs;
-  defaultRunScope = pkgsWithoutFetchers // pkgs.xorg;
+  targetPkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs.targetPackages;
+  defaultHostTargetScope = pkgsWithoutFetchers // pkgs.xorg;
+  defaultTargetTargetScope = targetPkgsWithoutFetchers // targetPkgsWithoutFetchers.xorg or {};
 
-  splicer = buildPkgs: runPkgs: let
-    mash = buildPkgs // runPkgs;
+  splicer = pkgsBuildBuild: pkgsBuildHost: pkgsBuildTarget:
+            pkgsHostHost: pkgsHostTarget:
+            pkgsTargetTarget: let
+    mash =
+      # Other pkgs sets
+      pkgsBuildBuild // pkgsBuildTarget // pkgsHostHost // pkgsTargetTarget
+      # The same pkgs sets one probably intends
+      // pkgsBuildHost // pkgsHostTarget;
     merge = name: {
       inherit name;
       value = let
         defaultValue = mash.${name};
         # `or {}` is for the non-derivation attsert splicing case, where `{}` is the identity.
-        buildValue = buildPkgs.${name} or {};
-        runValue = runPkgs.${name} or {};
+        valueBuildBuild = pkgsBuildBuild.${name} or {};
+        valueBuildHost = pkgsBuildHost.${name} or {};
+        valueBuildTarget = pkgsBuildTarget.${name} or {};
+        valueHostHost = throw "`valueHostHost` unimplemented: pass manually rather than relying on splicer.";
+        valueHostTarget = pkgsHostTarget.${name} or {};
+        valueTargetTarget = pkgsTargetTarget.${name} or {};
         augmentedValue = defaultValue
-          // (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; })
-          // (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; });
+          # TODO(@Ericson2314): Stop using old names after transition period
+          // (lib.optionalAttrs (pkgsBuildHost ? ${name}) { nativeDrv = valueBuildHost; })
+          // (lib.optionalAttrs (pkgsHostTarget ? ${name}) { crossDrv = valueHostTarget; })
+          // {
+            __spliced =
+                 (lib.optionalAttrs (pkgsBuildBuild ? ${name}) { buildBuild = valueBuildBuild; })
+              // (lib.optionalAttrs (pkgsBuildTarget ? ${name}) { buildTarget = valueBuildTarget; })
+              // { hostHost = valueHostHost; }
+              // (lib.optionalAttrs (pkgsTargetTarget ? ${name}) { targetTarget = valueTargetTarget;
+          });
+        };
         # Get the set of outputs of a derivation. If one derivation fails to
         # evaluate we don't want to diverge the entire splice, so we fall back
         # on {}
@@ -55,10 +82,15 @@ let
       in
         # The derivation along with its outputs, which we recur
         # on to splice them together.
-        if lib.isDerivation defaultValue then augmentedValue
-          // splicer (tryGetOutputs buildValue) (getOutputs runValue)
+        if lib.isDerivation defaultValue then augmentedValue // splicer
+          (tryGetOutputs valueBuildBuild) (tryGetOutputs valueBuildHost) (tryGetOutputs valueBuildTarget)
+          (tryGetOutputs valueHostHost) (getOutputs valueHostTarget)
+          (tryGetOutputs valueTargetTarget)
         # Just recur on plain attrsets
-        else if lib.isAttrs defaultValue then splicer buildValue runValue
+        else if lib.isAttrs defaultValue then splicer
+          valueBuildBuild valueBuildHost valueBuildTarget
+          {} valueHostTarget
+          valueTargetTarget
         # Don't be fancy about non-derivations. But we could have used used
         # `__functor__` for functions instead.
         else defaultValue;
@@ -67,11 +99,16 @@ let
 
   splicedPackages =
     if actuallySplice
-    then splicer defaultBuildScope defaultRunScope // {
-      # These should never be spliced under any circumstances
-      inherit (pkgs) pkgs buildPackages targetPackages
-        buildPlatform targetPlatform hostPlatform;
-    }
+    then
+      splicer
+        defaultBuildBuildScope defaultBuildHostScope defaultBuildTargetScope
+        defaultHostHostScope defaultHostTargetScope
+        defaultTargetTargetScope
+      // {
+        # These should never be spliced under any circumstances
+        inherit (pkgs) pkgs buildPackages targetPackages
+          buildPlatform targetPlatform hostPlatform;
+      }
     else pkgs // pkgs.xorg;
 
 in