From a6218c058b3e994779147dd7286606c750be7d73 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 18 Nov 2020 12:12:34 -0500 Subject: lib: Create `makeScopeWithSplicing` It's ugly as hell, but I suppose it is needed to codify how to make spliced package sets. --- lib/customisation.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'lib/customisation.nix') diff --git a/lib/customisation.nix b/lib/customisation.nix index dc5dd769197..37a7951896b 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -217,4 +217,31 @@ rec { }; in self; + /* Like the above, but aims to support cross compilation. It's still ugly, but + hopefully it helps a little bit. */ + makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: f: + let + spliced = splicePackages { + pkgsBuildBuild = otherSplices.selfBuildBuild; + pkgsBuildHost = otherSplices.selfBuildHost; + pkgsBuildTarget = otherSplices.selfBuildTarget; + pkgsHostHost = otherSplices.selfHostHost; + pkgsHostTarget = self; # Not `otherSplices.selfHostTarget`; + pkgsTargetTarget = otherSplices.selfTargetTarget; + } // keep self; + self = f self // { + newScope = scope: newScope (spliced // scope); + callPackage = newScope spliced; # == self.newScope {}; + # N.B. the other stages of the package set spliced in are *not* + # overridden. + overrideScope = g: makeScopeWithSplicing + splicePackages + newScope + otherSplices + keep + (lib.fixedPoints.extends g f); + packages = f; + }; + in self; + } -- cgit 1.4.1