···166 overrideWith = newArgs: origArgs // (if isFunction newArgs then newArgs origArgs else newArgs);
167168 # Re-call the function but with different arguments
169- overrideArgs = mirrorArgs (newArgs: makeOverridable f (overrideWith newArgs));
000000000170 # Change the result of the function call by applying g to it
171 overrideResult = g: makeOverridable (mirrorArgs (args: g (f args))) origArgs;
172 in
···176 override = overrideArgs;
177 overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
178 ${if result ? overrideAttrs then "overrideAttrs" else null} =
0000000000179 fdrv: overrideResult (x: x.overrideAttrs fdrv);
180 }
181 else if isFunction result then
···166 overrideWith = newArgs: origArgs // (if isFunction newArgs then newArgs origArgs else newArgs);
167168 # Re-call the function but with different arguments
169+ overrideArgs = mirrorArgs (
170+ /**
171+ Change the arguments with which a certain function is called.
172+173+ In some cases, you may find a list of possible attributes to pass in this function's `__functionArgs` attribute, but it will not be complete for an original function like `args@{foo, ...}: ...`, which accepts arbitrary attributes.
174+175+ This function was provided by `lib.makeOverridable`.
176+ */
177+ newArgs: makeOverridable f (overrideWith newArgs)
178+ );
179 # Change the result of the function call by applying g to it
180 overrideResult = g: makeOverridable (mirrorArgs (args: g (f args))) origArgs;
181 in
···185 override = overrideArgs;
186 overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
187 ${if result ? overrideAttrs then "overrideAttrs" else null} =
188+ /**
189+ Override the attributes that were passed to `mkDerivation` in order to generate this derivation.
190+191+ This function is provided by `lib.makeOverridable`, and indirectly by `callPackage` among others, in order to make the combination of `override` and `overrideAttrs` work.
192+ Specifically, it re-adds the `override` attribute to the result of `overrideAttrs`.
193+194+ The real implementation of `overrideAttrs` is provided by `stdenv.mkDerivation`.
195+ */
196+ # NOTE: part of the above documentation had to be duplicated in `mkDerivation`'s `overrideAttrs`.
197+ # design/tech debt issue: https://github.com/NixOS/nixpkgs/issues/273815
198 fdrv: overrideResult (x: x.overrideAttrs fdrv);
199 }
200 else if isFunction result then
···84 args = rattrs (args // { inherit finalPackage overrideAttrs; });
85 # ^^^^
8687+ /**
88+ Override the attributes that were passed to `mkDerivation` in order to generate this derivation.
89+ */
90+ # NOTE: the above documentation had to be duplicated in `lib/customisation.nix`: `makeOverridable`.
91 overrideAttrs =
92 f0:
93 let