Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: less indented if-then-else #190

Merged
merged 1 commit into from
Feb 23, 2022
Merged

feat: less indented if-then-else #190

merged 1 commit into from
Feb 23, 2022

Conversation

kamadorueda
Copy link
Owner

diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 5d3d7b464..909dc25f7 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -156,14 +156,13 @@ in rec {
           v = set.${name};
         in
           if pred name v
-          then
-            [
-              (nameValuePair name (
-                if isAttrs v
-                then filterAttrsRecursive pred v
-                else v
-              ))
-            ]
+          then [
+            (nameValuePair name (
+              if isAttrs v
+              then filterAttrsRecursive pred v
+              else v
+            ))
+          ]
           else []
       ) (attrNames set)
     );
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 9c82f04ba..abd8b0a36 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -38,11 +38,10 @@
       }
       // (drv.passthru or {})
       // (if (drv ? crossDrv && drv ? nativeDrv)
-      then
-        {
-          crossDrv = overrideDerivation drv.crossDrv f;
-          nativeDrv = overrideDerivation drv.nativeDrv f;
-        }
+      then {
+        crossDrv = overrideDerivation drv.crossDrv f;
+        nativeDrv = overrideDerivation drv.nativeDrv f;
+      }
       else {})
     );
 
diff --git a/lib/debug.nix b/lib/debug.nix
index c869e9b84..7208484a6 100644
--- a/lib/debug.nix
+++ b/lib/debug.nix
@@ -226,14 +226,13 @@ in rec {
         (substring 0 4 name == "test" || elem name testsToRun)
         && ((testsToRun == []) || elem name tests.tests)
         && (test.expr != test.expected)
-      then
-        [
-          {
-            inherit name;
-            expected = test.expected;
-            result = test.expr;
-          }
-        ]
+      then [
+        {
+          inherit name;
+          expected = test.expected;
+          result = test.expr;
+        }
+      ]
       else []) tests));
 
   /*
@@ -335,21 +334,19 @@ in rec {
     + "Please complain if you use the function regularly.")
     (if !isInt a
     then traceCallXml 1 "calling ${a}\n"
-    else
-      let
-        nr = a;
-      in (
-        str: expr:
-          if isFunction expr
-          then
-            (
-              arg:
-                traceCallXml (builtins.add 1 nr) "${str}\n arg ${builtins.toString nr} is \n ${builtins.toXML (builtins.seq arg arg)}" (expr arg)
-            )
-          else
-            let
-              r = builtins.seq expr expr;
-            in
-              trace "${str}\n result:\n${builtins.toXML r}" r
-      ));
+    else let
+      nr = a;
+    in (
+      str: expr:
+        if isFunction expr
+        then
+          (
+            arg:
+              traceCallXml (builtins.add 1 nr) "${str}\n arg ${builtins.toString nr} is \n ${builtins.toXML (builtins.seq arg arg)}" (expr arg)
+          )
+        else let
+          r = builtins.seq expr expr;
+        in
+          trace "${str}\n result:\n${builtins.toXML r}" r
+    ));
 }
diff --git a/lib/deprecated.nix b/lib/deprecated.nix
index a8a420b8c..432efc599 100644
--- a/lib/deprecated.nix
+++ b/lib/deprecated.nix
@@ -71,16 +71,15 @@ in
     then true
     else if argList == []
     then null
-    else
-      let
-        x = builtins.head argList;
-      in
-        if (head x) == name
-        then (head (tail x))
-        else
-          (getValue attrSet
-          (tail argList)
-          name))
+    else let
+      x = builtins.head argList;
+    in
+      if (head x) == name
+      then (head (tail x))
+      else
+        (getValue attrSet
+        (tail argList)
+        name))
     attrSet);
 
     # Input : attrSet, [[name default] ...], [ [flagname reqs..] ... ]
@@ -107,15 +106,14 @@ in
       go = xs: acc:
         if xs == []
         then []
-        else
-          let
-            x = head xs;
-            y =
-              if elem x acc
-              then []
-              else [x];
-          in
-            y ++ go (tail xs) (y ++ acc);
+        else let
+          x = head xs;
+          y =
+            if elem x acc
+            then []
+            else [x];
+        in
+          y ++ go (tail xs) (y ++ acc);
     in
       go inputList acc;
 
@@ -127,21 +125,20 @@ in
     }:
       if inputList == []
       then outputList
-      else
-        let
-          x = head inputList;
-          isX = y: (compare (getter y) (getter x));
-          newOutputList =
-            outputList
-            ++ (if any isX outputList
-            then []
-            else [x]);
-        in
-          uniqListExt {
-            outputList = newOutputList;
-            inputList = (tail inputList);
-            inherit getter compare;
-          };
+      else let
+        x = head inputList;
+        isX = y: (compare (getter y) (getter x));
+        newOutputList =
+          outputList
+          ++ (if any isX outputList
+          then []
+          else [x]);
+      in
+        uniqListExt {
+          outputList = newOutputList;
+          inputList = (tail inputList);
+          inherit getter compare;
+        };

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant