about summary refs log tree commit diff
path: root/pkgs/stdenv
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-22 11:42:51 -0400
committerEelco Dolstra <eelco.dolstra@logicblox.com>2012-08-22 15:43:18 -0400
commit85047983a152b55e01f01ca6ee984696af9da684 (patch)
tree8e8e1fb366ec06c744f103e4a810efd71854021f /pkgs/stdenv
parentcdc0c13c00c7b22d25b44d64151cc8f9e94d5d96 (diff)
downloadnixlib-85047983a152b55e01f01ca6ee984696af9da684.tar
nixlib-85047983a152b55e01f01ca6ee984696af9da684.tar.gz
nixlib-85047983a152b55e01f01ca6ee984696af9da684.tar.bz2
nixlib-85047983a152b55e01f01ca6ee984696af9da684.tar.lz
nixlib-85047983a152b55e01f01ca6ee984696af9da684.tar.xz
nixlib-85047983a152b55e01f01ca6ee984696af9da684.tar.zst
nixlib-85047983a152b55e01f01ca6ee984696af9da684.zip
stdenv/generic/default.nix: Simplify the code using the "or" construct
Diffstat (limited to 'pkgs/stdenv')
-rw-r--r--pkgs/stdenv/generic/default.nix31
1 files changed, 11 insertions, 20 deletions
diff --git a/pkgs/stdenv/generic/default.nix b/pkgs/stdenv/generic/default.nix
index a3284bea8e47..3555ea980150 100644
--- a/pkgs/stdenv/generic/default.nix
+++ b/pkgs/stdenv/generic/default.nix
@@ -42,30 +42,23 @@ let
           (derivation (
             (removeAttrs attrs ["meta" "passthru" "crossAttrs"])
             // (let
-                buildInputs = if attrs ? buildInputs then attrs.buildInputs
-                    else [];
-                buildNativeInputs = if attrs ? buildNativeInputs then
-                    attrs.buildNativeInputs else [];
-                propagatedBuildInputs = if attrs ? propagatedBuildInputs then
-                    attrs.propagatedBuildInputs else [];
-                propagatedBuildNativeInputs = if attrs ?
-                    propagatedBuildNativeInputs then
-                    attrs.propagatedBuildNativeInputs else [];
-                crossConfig = if (attrs ? crossConfig) then attrs.crossConfig else
-                   null;
+              buildInputs = attrs.buildInputs or [];
+              buildNativeInputs = attrs.buildNativeInputs or [];
+              propagatedBuildInputs = attrs.propagatedBuildInputs or [];
+              propagatedBuildNativeInputs = attrs.propagatedBuildNativeInputs or [];
+              crossConfig = attrs.crossConfig or null;
             in
             {
-              builder = if attrs ? realBuilder then attrs.realBuilder else shell;
-              args = if attrs ? args then attrs.args else
-                ["-e" (if attrs ? builder then attrs.builder else ./default-builder.sh)];
+              builder = attrs.realBuilder or shell;
+              args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
               stdenv = result;
               system = result.system;
 
-              # That build by the cross compiler
+              # Inputs built by the cross compiler.
               buildInputs = lib.optionals (crossConfig != null) buildInputs;
               propagatedBuildInputs = lib.optionals (crossConfig != null)
                   propagatedBuildInputs;
-              # That build by the usual native compiler
+              # Inputs built by the usual native compiler.
               buildNativeInputs = buildNativeInputs ++ lib.optionals
                 (crossConfig == null) buildInputs;
               propagatedBuildNativeInputs = propagatedBuildNativeInputs ++
@@ -77,13 +70,11 @@ let
           # passed to the builder and is not a dependency.  But since we
           # include it in the result, it *is* available to nix-env for
           # queries.
-          //
-          { meta = if attrs ? meta then attrs.meta else {}; }
+          // { meta = attrs.meta or {}; }
           # Pass through extra attributes that are not inputs, but
           # should be made available to Nix expressions using the
           # derivation (e.g., in assertions).
-          //
-          (if attrs ? passthru then attrs.passthru else {});
+          // (attrs.passthru or {});
 
         # Utility flags to test the type of platform.
         isDarwin = result.system == "i686-darwin"