summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
Diffstat (limited to 'lib/trivial.nix')
-rw-r--r--lib/trivial.nix3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/trivial.nix b/lib/trivial.nix
index 62906339e60..735aa55e0dc 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -122,6 +122,9 @@ rec {
   # Flip the order of the arguments of a binary function.
   flip = f: a: b: f b a;
 
+  # Apply function if argument is non-null
+  mapNullable = f: a: if isNull a then a else f a;
+
   # Pull in some builtins not included elsewhere.
   inherit (builtins)
     pathExists readFile isBool isFunction