stdenvAdapters: add overrideMkDerivationArgs
In addition to the use-case mentioned inside the function's documentation comment, I am motivated to add this function for two reasons: - My actual use-case is adding a guaranteed phase to every `stdenv.mkDerivation` via a nixpkgs overlay. Exposing this generic function allows me to do that, without having to replicate `defaultMkDerivationFromStdenv`. This relieves that maintainence burden for that overlay implementation, since that function has to be kept in sync with `stdenv/generic`. - I see value in adding this generic function over a specialized function. At first, I had a different implementation in mind, and tried to make due with the specialized functions that were already exposed. Having access to this generic function allowed me to experiment, and settle on a better implementation. This commit is based off of @SomeoneSerge's PR [1]. [1] https://github.com/NixOS/nixpkgs/pull/350350 Co-authored-by: SomeoneSerge <else+aalto@someonex.net>
This commit is contained in:
co-authored by
SomeoneSerge
parent
e0239fe703
commit
3c4cf6301a
@@ -215,6 +215,23 @@ rec {
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs old (_: extraAttrs);
|
||||
});
|
||||
|
||||
/*
|
||||
Modify a stdenv so as to extend `mkDerivation`'s arguments.
|
||||
A stronger version of `addAttrsToDerivation`.
|
||||
|
||||
Example:
|
||||
requireCcache =
|
||||
overrideMkDerivationArgs
|
||||
(oldAttrs: {
|
||||
requiredSystemFeatures = oldAttrs.requiredSystemFeatures or [ ] ++ [ "ccache" ];
|
||||
});
|
||||
*/
|
||||
overrideMkDerivationArgs =
|
||||
extension: stdenv:
|
||||
stdenv.override (old: {
|
||||
mkDerivationFromStdenv = extendMkDerivationArgs old extension;
|
||||
});
|
||||
|
||||
/*
|
||||
Use the trace output to report all processed derivations with their
|
||||
license name.
|
||||
|
||||
Reference in New Issue
Block a user