query
On this page

overrideExisting

lib.attrsets.overrideExisting

Docs pulled from | This Revision | about 2 hours ago


Override only the attributes that are already present in the old set useful for deep-overriding.

Inputs

old

Original attribute set

new

Attribute set with attributes to override in old.

Type

overrideExisting :: AttrSet -> AttrSet -> AttrSet

Examples

lib.attrsets.overrideExisting usage example

overrideExisting {} { a = 1; }
=> {}
overrideExisting { b = 2; } { a = 1; }
=> { b = 2; }
overrideExisting { a = 3; b = 2; } { a = 1; }
=> { a = 1; b = 2; }

Noogle detected

Aliases

Implementation

The following is the current implementation of this function.

overrideExisting =
    old:
    new:
    mapAttrs (name: value: new.${name} or value) old;