summary refs log tree commit diff
path: root/lib/customisation.nix
diff options
context:
space:
mode:
authorJohn Ericson <John.Ericson@Obsidian.Systems>2018-09-23 11:07:35 -0400
committerJohn Ericson <John.Ericson@Obsidian.Systems>2018-09-24 17:50:11 -0400
commitb9dce11712d2bfc8cd367df5a7f737a5cec1e252 (patch)
tree1adf097b9eba03bbcca2e09fdef9a11c2c7543d6 /lib/customisation.nix
parent84c8e397d234bcdbd7ee4a41bf6b705d1250250c (diff)
downloadnixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar.gz
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar.bz2
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar.lz
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar.xz
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.tar.zst
nixpkgs-b9dce11712d2bfc8cd367df5a7f737a5cec1e252.zip
lib: Make `overrideScope'` which takes arguments in the conventional order
The `overrideScope` bound by `makeScope` (via special `callPackage`)
took an override in the form `super: self { … }`. But this is
dangerously close to the `self: super { … }` form used by *everything*
else, even other definitions of `overrideScope`! Since that
implementation did not even share any code either until I changed it
recently in 3cf43547f4be03d1d6eb0bbfc557e2dbc13b4095, this inconsistency
is almost certainly an oversight and not intentional.

Unfortunately, just as the inconstency is hard to debug if one just
assumes the conventional order, any sudden fix would break existing
overrides in the same hard-to-debug way. So instead of changing the
definition a new `overrideScope'` with the conventional order is added,
and old `overrideScope` deprecated with a warning saying to use
`overrideScope'` instead. That will hopefully get people to stop using
`overrideScope`, freeing our hand to change or remove it in the future.
Diffstat (limited to 'lib/customisation.nix')
-rw-r--r--lib/customisation.nix10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 0107ed33d9e..df9d977e9ec 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -185,7 +185,7 @@ rec {
   /* Make a set of packages with a common scope. All packages called
      with the provided `callPackage' will be evaluated with the same
      arguments. Any package in the set may depend on any other. The
-     `overrideScope' function allows subsequent modification of the package
+     `overrideScope'` function allows subsequent modification of the package
      set in a consistent way, i.e. all packages in the set will be
      called with the overridden packages. The package sets may be
      hierarchical: the packages in the set are called with the scope
@@ -195,10 +195,10 @@ rec {
     let self = f self // {
           newScope = scope: newScope (self // scope);
           callPackage = self.newScope {};
-          # TODO(@Ericson2314): Haromonize argument order of `g` with everything else
-          overrideScope = g:
-            makeScope newScope
-            (lib.fixedPoints.extends (lib.flip g) f);
+          overrideScope = g: lib.warn
+            "`overrideScope` (from `lib.makeScope`) is deprecated. Do `overrideScope' (self: self: { … })` instead of `overrideScope (super: self: { … })`. All other overrides have the parameters in that order, including other definitions of `overrideScope`. This was the only definition violating the pattern."
+            (makeScope newScope (lib.fixedPoints.extends (lib.flip g) f));
+          overrideScope' = g: makeScope newScope (lib.fixedPoints.extends g f);
           packages = f;
         };
     in self;