+20
-1
lib/customisation.nix
+20
-1
lib/customisation.nix
···
166
166
overrideWith = newArgs: origArgs // (if isFunction newArgs then newArgs origArgs else newArgs);
167
167
168
168
# Re-call the function but with different arguments
169
-
overrideArgs = mirrorArgs (newArgs: makeOverridable f (overrideWith newArgs));
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
+
);
170
179
# Change the result of the function call by applying g to it
171
180
overrideResult = g: makeOverridable (mirrorArgs (args: g (f args))) origArgs;
172
181
in
···
176
185
override = overrideArgs;
177
186
overrideDerivation = fdrv: overrideResult (x: overrideDerivation x fdrv);
178
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
179
198
fdrv: overrideResult (x: x.overrideAttrs fdrv);
180
199
}
181
200
else if isFunction result then
+4
pkgs/stdenv/generic/make-derivation.nix
+4
pkgs/stdenv/generic/make-derivation.nix
···
84
84
args = rattrs (args // { inherit finalPackage overrideAttrs; });
85
85
# ^^^^
86
86
87
+
/**
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`.
87
91
overrideAttrs =
88
92
f0:
89
93
let