Merge pull request #248988 from Artturin/matchoscopes
lib.customisation.makeScope: Make `overrideScope` consistent with `makeScopeWithSplicing`
This commit is contained in:
commit
300da0a691
@ -103,14 +103,14 @@ You can install it like any other packages via `nix-env -iA myEmacs`. However, t
|
||||
|
||||
This provides a fairly full Emacs start file. It will load in addition to the user's personal config. You can always disable it by passing `-q` to the Emacs command.
|
||||
|
||||
Sometimes `emacs.pkgs.withPackages` is not enough, as this package set has some priorities imposed on packages (with the lowest priority assigned to Melpa Unstable, and the highest for packages manually defined in `pkgs/top-level/emacs-packages.nix`). But you can't control these priorities when some package is installed as a dependency. You can override it on a per-package-basis, providing all the required dependencies manually, but it's tedious and there is always a possibility that an unwanted dependency will sneak in through some other package. To completely override such a package, you can use `overrideScope'`.
|
||||
Sometimes `emacs.pkgs.withPackages` is not enough, as this package set has some priorities imposed on packages (with the lowest priority assigned to Melpa Unstable, and the highest for packages manually defined in `pkgs/top-level/emacs-packages.nix`). But you can't control these priorities when some package is installed as a dependency. You can override it on a per-package-basis, providing all the required dependencies manually, but it's tedious and there is always a possibility that an unwanted dependency will sneak in through some other package. To completely override such a package, you can use `overrideScope`.
|
||||
|
||||
```nix
|
||||
overrides = self: super: rec {
|
||||
haskell-mode = self.melpaPackages.haskell-mode;
|
||||
...
|
||||
};
|
||||
((emacsPackagesFor emacs).overrideScope' overrides).withPackages
|
||||
((emacsPackagesFor emacs).overrideScope overrides).withPackages
|
||||
(p: with p; [
|
||||
# here both these package will use haskell-mode of our own choice
|
||||
ghc-mod
|
||||
|
@ -30,7 +30,7 @@ package set to make it the default. This guarantees you get a consistent package
|
||||
set.
|
||||
```nix
|
||||
mypkg = let
|
||||
cudaPackages = cudaPackages_11_5.overrideScope' (final: prev: {
|
||||
cudaPackages = cudaPackages_11_5.overrideScope (final: prev: {
|
||||
cudnn = prev.cudnn_8_3;
|
||||
}});
|
||||
in callPackage { inherit cudaPackages; };
|
||||
|
@ -269,10 +269,11 @@ rec {
|
||||
let self = f self // {
|
||||
newScope = scope: newScope (self // scope);
|
||||
callPackage = self.newScope {};
|
||||
overrideScope = g: lib.warn
|
||||
"`overrideScope` (from `lib.makeScope`) is deprecated. Do `overrideScope' (self: super: { … })` 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);
|
||||
overrideScope = g: makeScope newScope (lib.fixedPoints.extends g f);
|
||||
# Remove after 24.11 is released.
|
||||
overrideScope' = g: lib.warnIf (lib.isInOldestRelease 2311)
|
||||
"`overrideScope'` (from `lib.makeScope`) has been renamed to `overrideScope`."
|
||||
(makeScope newScope (lib.fixedPoints.extends g f));
|
||||
packages = f;
|
||||
};
|
||||
in self;
|
||||
|
@ -21,7 +21,7 @@ set which contains `emacs.pkgs.withPackages`. For example, to override
|
||||
`emacs.pkgs.emacs.pkgs.withPackages`,
|
||||
```
|
||||
let customEmacsPackages =
|
||||
emacs.pkgs.overrideScope' (self: super: {
|
||||
emacs.pkgs.overrideScope (self: super: {
|
||||
# use a custom version of emacs
|
||||
emacs = ...;
|
||||
# use the unstable MELPA version of magit
|
||||
|
@ -48,7 +48,7 @@ in
|
||||
# Like `buildRustPackages`, but may also contain prebuilt binaries to
|
||||
# break cycle. Just like `bootstrapTools` for nixpkgs as a whole,
|
||||
# nothing in the final package set should refer to this.
|
||||
bootstrapRustPackages = self.buildRustPackages.overrideScope' (_: _:
|
||||
bootstrapRustPackages = self.buildRustPackages.overrideScope (_: _:
|
||||
lib.optionalAttrs (stdenv.buildPlatform == stdenv.hostPlatform)
|
||||
(selectRustPackage buildPackages).packages.prebuilt);
|
||||
bootRustPlatform = makeRustPlatform bootstrapRustPackages;
|
||||
|
@ -85,7 +85,7 @@ let
|
||||
|
||||
php-packages = (callPackage ../../../top-level/php-packages.nix {
|
||||
phpPackage = phpWithExtensions;
|
||||
}).overrideScope' packageOverrides;
|
||||
}).overrideScope packageOverrides;
|
||||
|
||||
allExtensionFunctions = prevExtensionFunctions ++ [ extensions ];
|
||||
enabledExtensions =
|
||||
|
@ -299,7 +299,7 @@ let
|
||||
}:
|
||||
let
|
||||
spec = { inherit pkg faslExt program flags asdf; };
|
||||
pkgs = (commonLispPackagesFor spec).overrideScope' packageOverrides;
|
||||
pkgs = (commonLispPackagesFor spec).overrideScope packageOverrides;
|
||||
withPackages = lispWithPackages pkgs;
|
||||
withOverrides = packageOverrides:
|
||||
wrapLisp {
|
||||
|
@ -50,7 +50,7 @@ let
|
||||
# lispLibs ofpackages in this file.
|
||||
ql = quicklispPackagesFor spec;
|
||||
|
||||
packages = ql.overrideScope' (self: super: {
|
||||
packages = ql.overrideScope (self: super: {
|
||||
|
||||
cffi = let
|
||||
jna = pkgs.fetchMavenArtifact {
|
||||
|
@ -266,4 +266,4 @@ let
|
||||
lib.optionalAttrs (builtins.pathExists ./imported.nix)
|
||||
(pkgs.callPackage ./imported.nix { inherit build-asdf-system; });
|
||||
|
||||
in qlpkgs.overrideScope' overrides
|
||||
in qlpkgs.overrideScope overrides
|
||||
|
@ -70,4 +70,4 @@ let
|
||||
cutensorExtension
|
||||
]);
|
||||
|
||||
in (scope.overrideScope' composedExtension)
|
||||
in (scope.overrideScope composedExtension)
|
||||
|
@ -1803,7 +1803,7 @@ let
|
||||
|
||||
### End ###
|
||||
|
||||
})).overrideScope' liftJaneStreet;
|
||||
})).overrideScope liftJaneStreet;
|
||||
|
||||
in let inherit (pkgs) callPackage; in rec
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user