summary refs log tree commit diff
path: root/lib/trivial.nix
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2017-04-17 16:48:10 -0400
committerJohn Ericson <Ericson2314@Yahoo.com>2017-04-17 17:04:04 -0400
commit85aa5005af530fef199cc41148e374e54d70e01e (patch)
tree296a184cc5e710e197f45a91babb107bf8509eae /lib/trivial.nix
parentf3055a3c508b6ff3e926ece201887467dc2b5d73 (diff)
downloadnixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar.gz
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar.bz2
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar.lz
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar.xz
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.tar.zst
nixpkgs-85aa5005af530fef199cc41148e374e54d70e01e.zip
Introduce `mapNullable` into lib and use it in a few places
Also simply some configure flag logic my grep also alerted me too.
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 40499b2b509..b7b9d25922a 100644
--- a/lib/trivial.nix
+++ b/lib/trivial.nix
@@ -108,6 +108,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