diff options
author | Aneesh Agrawal <aneeshusa@gmail.com> | 2016-08-19 22:21:32 -0400 |
---|---|---|
committer | Aneesh Agrawal <aneeshusa@gmail.com> | 2016-10-02 11:08:34 -0400 |
commit | 39b64b52ed349bb7b6f26f50013335d76d1605f6 (patch) | |
tree | 3fa9730b6bbfe9c998ad19b0de1ec0118ff09d0f /lib | |
parent | fbcb93852cb63aacf7a204e232bb1d1d1b602696 (diff) |
mkDerivation: add overrideAttrs function
This is similar to `overrideDerivation`, but overrides the arguments to `mkDerivation` instead of the underlying `derivation` call. Also update `makeOverridable` so that uses of `overrideAttrs` can be followed by `override` and `overrideDerivation`, i.e. they can be mix-and-matched.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/customisation.nix | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix index efe82d7866001..3e6e279824be4 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -56,16 +56,18 @@ rec { ff = f origArgs; overrideWith = newArgs: origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs); in - if builtins.isAttrs ff then (ff // - { override = newArgs: makeOverridable f (overrideWith newArgs); - overrideDerivation = fdrv: - makeOverridable (args: overrideDerivation (f args) fdrv) origArgs; - }) - else if builtins.isFunction ff then - { override = newArgs: makeOverridable f (overrideWith newArgs); - __functor = self: ff; - overrideDerivation = throw "overrideDerivation not yet supported for functors"; - } + if builtins.isAttrs ff then (ff // { + override = newArgs: makeOverridable f (overrideWith newArgs); + overrideDerivation = fdrv: + makeOverridable (args: overrideDerivation (f args) fdrv) origArgs; + ${if ff ? overrideAttrs then "overrideAttrs" else null} = fdrv: + makeOverridable (args: (f args).overrideAttrs fdrv) origArgs; + }) + else if builtins.isFunction ff then { + override = newArgs: makeOverridable f (overrideWith newArgs); + __functor = self: ff; + overrideDerivation = throw "overrideDerivation not yet supported for functors"; + } else ff; |