about summary refs log tree commit diff
path: root/pkgs
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 /pkgs
parent383706f36db17307b7c2650ad35773f6c5b410d1 (diff)
parent85aa5005af530fef199cc41148e374e54d70e01e (diff)
downloadnixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar.gz
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar.bz2
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar.lz
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar.xz
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.tar.zst
nixlib-37e5e71fdf098a45471537e9961672592ef6f72a.zip
Merge pull request #24974 from Ericson2314/mapNullable
Introduce `mapNullable` into lib and use it in a few places
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/libraries/wiredtiger/default.nix7
-rw-r--r--pkgs/os-specific/linux/nvidia-x11/generic.nix2
-rw-r--r--pkgs/servers/shishi/default.nix7
-rw-r--r--pkgs/tools/filesystems/ceph/generic.nix9
4 files changed, 13 insertions, 12 deletions
diff --git a/pkgs/development/libraries/wiredtiger/default.nix b/pkgs/development/libraries/wiredtiger/default.nix
index 347686014d1d..e4b95fc1cb9f 100644
--- a/pkgs/development/libraries/wiredtiger/default.nix
+++ b/pkgs/development/libraries/wiredtiger/default.nix
@@ -7,9 +7,10 @@
 
 with stdenv.lib;
 let
-  mkFlag = trueStr: falseStr: cond: name: val:
-    if cond == null then null else
-      "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
+  mkFlag = trueStr: falseStr: cond: name: val: "--"
+    + (if cond then trueStr else falseStr)
+    + name
+    + optionalString (val != null && cond != false) "=${val}";
   mkEnable = mkFlag "enable-" "disable-";
   mkWith = mkFlag "with-" "without-";
   mkOther = mkFlag "" "" true;
diff --git a/pkgs/os-specific/linux/nvidia-x11/generic.nix b/pkgs/os-specific/linux/nvidia-x11/generic.nix
index 44a96f9bc0db..9441ce772c83 100644
--- a/pkgs/os-specific/linux/nvidia-x11/generic.nix
+++ b/pkgs/os-specific/linux/nvidia-x11/generic.nix
@@ -85,7 +85,7 @@ let
         withGtk2 = preferGtk2;
         withGtk3 = !preferGtk2;
       };
-      persistenced = if persistencedSha256 == null then null else callPackage (import ./persistenced.nix self persistencedSha256) { };
+      persistenced = mapNullable (hash: callPackage (import ./persistenced.nix self hash) { }) persistencedSha256;
     };
 
     meta = with stdenv.lib; {
diff --git a/pkgs/servers/shishi/default.nix b/pkgs/servers/shishi/default.nix
index 3e340ba7df4b..535571f46e20 100644
--- a/pkgs/servers/shishi/default.nix
+++ b/pkgs/servers/shishi/default.nix
@@ -6,9 +6,10 @@
 }:
 
 let
-  mkFlag = trueStr: falseStr: cond: name: val:
-    if cond == null then null else
-      "--${if cond != false then trueStr else falseStr}${name}${if val != null && cond != false then "=${val}" else ""}";
+  mkFlag = trueStr: falseStr: cond: name: val: "--"
+    + (if cond then trueStr else falseStr)
+    + name
+    + stdenv.lib.optionalString (val != null && cond != false) "=${val}";
   mkEnable = mkFlag "enable-" "disable-";
   mkWith = mkFlag "with-" "without-";
   mkOther = mkFlag "" "" true;
diff --git a/pkgs/tools/filesystems/ceph/generic.nix b/pkgs/tools/filesystems/ceph/generic.nix
index d21d790dac81..e4c8b0f33bcd 100644
--- a/pkgs/tools/filesystems/ceph/generic.nix
+++ b/pkgs/tools/filesystems/ceph/generic.nix
@@ -31,11 +31,10 @@ with stdenv;
 with stdenv.lib;
 let
   inherit (python2Packages) python;
-  mkFlag = trueStr: falseStr: cond: name: val:
-    if cond == null then null else
-      "--${if cond != false then trueStr else falseStr}${name}"
-      + "${if val != null && cond != false then "=${val}" else ""}";
-
+  mkFlag = trueStr: falseStr: cond: name: val: "--"
+    + (if cond then trueStr else falseStr)
+    + name
+    + optionalString (val != null && cond != false) "=${val}";
   mkEnable = mkFlag "enable-" "disable-";
   mkWith = mkFlag "with-" "without-";
   mkOther = mkFlag "" "" true;