lib.customisation: add uncurried form of makeScopeWithSplicing

Deeply-curried functions are pretty error-prone in untyped languages
like Nix. This is a particularly bad case because
`top-level/splice.nix` *also* declares a makeScopeWithSplicing, but
it takes *two fewer arguments*.

Let's add a version that uses attrset-passing form, to provide some
minimal level of sanity-checking.

This also provides defaults for keep and extra (these are often
unneeded by the user).

authored by Adam Joseph and committed by Artturin a1fdbae7 b5f77af4

+23 -9
+21 -8
lib/customisation.nix
··· 277 277 }; 278 278 in self; 279 279 280 + /* backward compatibility with old uncurried form; deprecated */ 281 + makeScopeWithSplicing = 282 + splicePackages: newScope: otherSplices: keep: extra: f: 283 + makeScopeWithSplicing' { 284 + inherit splicePackages newScope otherSplices keep extra f; 285 + }; 286 + 280 287 /* Like the above, but aims to support cross compilation. It's still ugly, but 281 288 hopefully it helps a little bit. */ 282 - makeScopeWithSplicing = splicePackages: newScope: otherSplices: keep: extra: f: 289 + makeScopeWithSplicing' = 290 + { splicePackages 291 + , newScope 292 + }: 293 + { otherSplices 294 + , keep ? (_self: {}) 295 + , extra ? (_spliced0: {}) 296 + , f 297 + }: 283 298 let 284 299 spliced0 = splicePackages { 285 300 pkgsBuildBuild = otherSplices.selfBuildBuild; ··· 295 310 callPackage = newScope spliced; # == self.newScope {}; 296 311 # N.B. the other stages of the package set spliced in are *not* 297 312 # overridden. 298 - overrideScope = g: makeScopeWithSplicing 299 - splicePackages 300 - newScope 301 - otherSplices 302 - keep 303 - extra 304 - (lib.fixedPoints.extends g f); 313 + overrideScope = g: (makeScopeWithSplicing' 314 + { inherit splicePackages newScope; } 315 + { inherit otherSplices keep extra; 316 + f = lib.fixedPoints.extends g f; 317 + }); 305 318 packages = f; 306 319 }; 307 320 in self;
+1 -1
lib/default.nix
··· 112 112 noDepEntry fullDepEntry packEntry stringAfter; 113 113 inherit (self.customisation) overrideDerivation makeOverridable 114 114 callPackageWith callPackagesWith extendDerivation hydraJob 115 - makeScope makeScopeWithSplicing; 115 + makeScope makeScopeWithSplicing makeScopeWithSplicing'; 116 116 inherit (self.derivations) lazyDerivation; 117 117 inherit (self.meta) addMetaAttrs dontDistribute setName updateName 118 118 appendToName mapDerivationAttrset setPrio lowPrio lowPrioSet hiPrio
+1
pkgs/top-level/splice.nix
··· 145 145 146 146 # prefill 2 fields of the function for convenience 147 147 makeScopeWithSplicing = lib.makeScopeWithSplicing splicePackages pkgs.newScope; 148 + makeScopeWithSplicing' = lib.makeScopeWithSplicing' { inherit splicePackages; inherit (pkgs) newScope; }; 148 149 149 150 # generate 'otherSplices' for 'makeScopeWithSplicing' 150 151 generateSplicesForMkScope = attr: