summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@yahoo.com>2017-04-17 17:12:14 -0400
committerGitHub <noreply@github.com>2017-04-17 17:12:14 -0400
commit37e5e71fdf098a45471537e9961672592ef6f72a (patch)
tree43eb5da139409f5882c5b3194192a7088fba231f /lib/trivial.nix
parent383706f36db17307b7c2650ad35773f6c5b410d1 (diff)
parent85aa5005af530fef199cc41148e374e54d70e01e (diff)
downloadnixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar.gz
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar.bz2
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar.lz
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar.xz
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.tar.zst
nixpkgs-37e5e71fdf098a45471537e9961672592ef6f72a.zip
Merge pull request #24974 from Ericson2314/mapNullable
Introduce `mapNullable` into lib and use it in a few places
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