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: no space in empty containers #113

Merged
merged 3 commits into from
Feb 17, 2022
Merged

feat: no space in empty containers #113

merged 3 commits into from
Feb 17, 2022

Conversation

kamadorueda
Copy link
Owner

diff --git a/doc/default.nix b/doc/default.nix
index 53e101994..c485d486e 100644
--- a/doc/default.nix
+++ b/doc/default.nix
@@ -1,6 +1,6 @@
 {
-  pkgs ? (import ./.. { }),
-  nixpkgs ? { },
+  pkgs ? (import ./.. {}),
+  nixpkgs ? {},
 }:
 let
   lib = pkgs.lib;
diff --git a/doc/doc-support/default.nix b/doc/doc-support/default.nix
index ce7c3359b..4a7cf537e 100644
--- a/doc/doc-support/default.nix
+++ b/doc/doc-support/default.nix
@@ -1,6 +1,6 @@
 {
-  pkgs ? (import ../.. { }),
-  nixpkgs ? { },
+  pkgs ? (import ../.. {}),
+  nixpkgs ? {},
 }:
 let
   locationsXml = import ./lib-function-locations.nix { inherit pkgs nixpkgs; };
@@ -27,7 +27,7 @@ let
     </xsl:stylesheet>
   '';
 in
-pkgs.runCommand "doc-support" { }
+pkgs.runCommand "doc-support" {}
 ''
   mkdir result
   (
diff --git a/doc/doc-support/lib-function-docs.nix b/doc/doc-support/lib-function-docs.nix
index c634611dc..2c84abfc3 100644
--- a/doc/doc-support/lib-function-docs.nix
+++ b/doc/doc-support/lib-function-docs.nix
@@ -2,7 +2,7 @@
 # another library function file to this list, the include list in the
 # file `doc/functions/library.xml` must also be updated.
 {
-  pkgs ? import ./.. { },
+  pkgs ? import ./.. {},
   locationsXml,
 }:
 with pkgs;
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
   name = "nixpkgs-lib-docs";
   src = ./../../lib;
 
-  buildInputs = [ nixdoc ];
+  buildInputs = [nixdoc];
   installPhase = ''
     function docgen {
       nixdoc -c "$1" -d "$2" -f "../lib/$1.nix"  > "$out/$1.xml"
diff --git a/doc/doc-support/lib-function-locations.nix b/doc/doc-support/lib-function-locations.nix
index 815a8f3a7..5528d1ef9 100644
--- a/doc/doc-support/lib-function-locations.nix
+++ b/doc/doc-support/lib-function-locations.nix
@@ -1,6 +1,6 @@
 {
-  pkgs ? (import ./.. { }),
-  nixpkgs ? { },
+  pkgs ? (import ./.. {}),
+  nixpkgs ? {},
 }:
 let
   revision = pkgs.lib.trivial.revisionWithDefault (nixpkgs.revision or "master");
@@ -76,8 +76,8 @@ let
 
   relativeLocs = (builtins.map fnLocationRelative liblocations);
   sanitizeId = builtins.replaceStrings
-  [ "'" ]
-  [ "-prime" ];
+  ["'"]
+  ["-prime"];
 
   urlPrefix = "https://github.com/NixOS/nixpkgs/blob/${revision}";
   xmlstrings = (
diff --git a/doc/shell.nix b/doc/shell.nix
index 5fa2b4424..eef0a2b03 100644
--- a/doc/shell.nix
+++ b/doc/shell.nix
@@ -1,3 +1,3 @@
-{ pkgs ? import ../. { } }:
-(import ./default.nix { }).overrideAttrs
-(x: { buildInputs = (x.buildInputs or [ ]) ++ [ pkgs.xmloscopy pkgs.ruby ]; })
+{ pkgs ? import ../. {} }:
+(import ./default.nix {}).overrideAttrs
+(x: { buildInputs = (x.buildInputs or []) ++ [pkgs.xmloscopy pkgs.ruby]; })
diff --git a/lib/asserts.nix b/lib/asserts.nix
index 223e9dc7c..b6b7f4f8b 100644
--- a/lib/asserts.nix
+++ b/lib/asserts.nix
@@ -37,8 +37,8 @@ rec {
     assertMsg
     (lib.elem val xs)
     "${name} must be one of ${
-      lib.generators.toPretty { } xs
+      lib.generators.toPretty {} xs
     }, but is: ${
-      lib.generators.toPretty { } val
+      lib.generators.toPretty {} val
     }";
 }
diff --git a/lib/attrsets.nix b/lib/attrsets.nix
index 65fe860a1..7725a2b56 100644
--- a/lib/attrsets.nix
+++ b/lib/attrsets.nix
@@ -22,7 +22,7 @@ rec {
   attrByPath = attrPath: default: e: let
     attr = head attrPath;
   in
-    if attrPath == [ ]
+    if attrPath == []
     then e
     else if e ? ${attr}
     then attrByPath (tail attrPath) default e.${attr}
@@ -42,7 +42,7 @@ rec {
   hasAttrByPath = attrPath: e: let
     attr = head attrPath;
   in
-    if attrPath == [ ]
+    if attrPath == []
     then true
     else if e ? ${attr}
     then hasAttrByPath (tail attrPath) e.${attr}
@@ -125,8 +125,8 @@ rec {
           map (
             s:
               if s ? ${attr}
-              then [ s.${attr} ]
-              else [ ]
+              then [s.${attr}]
+              else []
           )
           l
         )
@@ -147,8 +147,8 @@ rec {
           v = set.${name};
         in
           if pred name v
-          then [ (nameValuePair name v) ]
-          else [ ]
+          then [(nameValuePair name v)]
+          else []
       ) (attrNames set)
     );
 
@@ -177,7 +177,7 @@ rec {
                 )
               )
             ]
-          else [ ]
+          else []
       ) (attrNames set)
     );
 
@@ -196,7 +196,7 @@ rec {
             o // { ${name} = op n.${name} (a.${name} or nul); }
         )
         a (attrNames n)
-    ) { };
+    ) {};
 
   /*
    Recursively collect sets that verify a given predicate named `pred'
@@ -217,10 +217,10 @@ rec {
    */
   collect = pred: attrs:
     if pred attrs
-    then [ attrs ]
+    then [attrs]
     else if isAttrs attrs
     then concatMap (collect pred) (attrValues attrs)
-    else [ ];
+    else [];
 
   /*
     Return the cartesian product of attribute set value combinations.
@@ -242,7 +242,7 @@ rec {
             map (listValue: attrs // { ${attrName} = listValue; }) attrsOfLists.${attrName}
         )
         listOfAttrs
-    ) [ { } ] (attrNames attrsOfLists);
+    ) [{}] (attrNames attrsOfLists);
 
   /*
    Utility function that creates a {name, value} pair as expected by
@@ -348,12 +348,12 @@ rec {
       g =
         name: value:
           if isAttrs value && cond value
-          then recurse (path ++ [ name ]) value
-          else f (path ++ [ name ]) value;
+          then recurse (path ++ [name]) value
+          else f (path ++ [name]) value;
     in
       mapAttrs g;
   in
-    recurse [ ] set;
+    recurse [] set;
 
   /*
    Generate an attribute set by mapping a function over a list of
@@ -389,7 +389,7 @@ rec {
         type = "derivation";
         name = sanitizeDerivationName (builtins.substring 33 (-1) (baseNameOf path'));
         outPath = path';
-        outputs = [ "out" ];
+        outputs = ["out"];
         out = res;
         outputName = "out";
       };
@@ -409,7 +409,7 @@ rec {
   optionalAttrs = cond: as:
     if cond
     then as
-    else { };
+    else {};
 
   /*
    Merge sets of attributes and use the function f to merge attributes
@@ -484,7 +484,7 @@ rec {
     f = attrPath:
       zipAttrsWith (
         n: values: let
-          here = attrPath ++ [ n ];
+          here = attrPath ++ [n];
         in
           if
             length values
@@ -494,7 +494,7 @@ rec {
           else f here values
       );
   in
-    f [ ] [ rhs lhs ];
+    f [] [rhs lhs];
 
   /*
    A recursive variant of the update operator ‘//’.  The recursion
@@ -539,7 +539,7 @@ rec {
             else if isAttrs pat
             then isAttrs val && matchAttrs pat val
             else pat == val
-        ) [ pattern attrs ]
+        ) [pattern attrs]
       )
     );
 
diff --git a/lib/cli.nix b/lib/cli.nix
index d8aefb808..de28a2f97 100644
--- a/lib/cli.nix
+++ b/lib/cli.nix
@@ -68,8 +68,8 @@ rec {
       mkOption ?
         k: v:
           if v == null
-          then [ ]
-          else [ (mkOptionName k) (lib.generators.mkValueStringDefault { } v) ],
+          then []
+          else [(mkOptionName k) (lib.generators.mkValueStringDefault {} v)],
     }:
       options: let
         render = k: v:
diff --git a/lib/customisation.nix b/lib/customisation.nix
index 7c5f2386e..3929494a2 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -31,13 +31,13 @@ rec {
   in
     lib.flip (extendDerivation true) newDrv (
       {
-        meta = drv.meta or { };
+        meta = drv.meta or {};
         passthru =
           if drv ? passthru
           then drv.passthru
-          else { };
+          else {};
       }
-      // (drv.passthru or { })
+      // (drv.passthru or {})
       // (
         if (drv ? crossDrv && drv ? nativeDrv)
         then
@@ -45,7 +45,7 @@ rec {
             crossDrv = overrideDerivation drv.crossDrv f;
             nativeDrv = overrideDerivation drv.nativeDrv f;
           }
-        else { }
+        else {}
       )
     );
 
@@ -170,7 +170,7 @@ rec {
    the derivation itself and check a given condition when evaluating.
    */
   extendDerivation = condition: passthru: drv: let
-    outputs = drv.outputs or [ "out" ];
+    outputs = drv.outputs or ["out"];
 
     commonAttrs =
       drv
@@ -205,7 +205,7 @@ rec {
    garbage collection.
    */
   hydraJob = drv: let
-    outputs = drv.outputs or [ "out" ];
+    outputs = drv.outputs or ["out"];
 
     commonAttrs =
       {
@@ -255,7 +255,7 @@ rec {
       f self
       // {
         newScope = scope: newScope (self // scope);
-        callPackage = self.newScope { };
+        callPackage = self.newScope {};
         overrideScope = g:
           lib.warn
           "`overrideScope` (from `lib.makeScope`) is deprecated. Do `overrideScope' (self: super: { … })` instead of `overrideScope (super: self: { … })`. All other overrides have the parameters in that order, including other definitions of `overrideScope`. This was the only definition violating the pattern."
diff --git a/lib/debug.nix b/lib/debug.nix
index 59c131a14..4ec26386d 100644
--- a/lib/debug.nix
+++ b/lib/debug.nix
@@ -224,11 +224,11 @@ rec {
       testsToRun =
         if tests ? tests
         then tests.tests
-        else [ ];
+        else [];
     in
       if
         (substring 0 4 name == "test" || elem name testsToRun)
-        && ((testsToRun == [ ]) || elem name tests.tests)
+        && ((testsToRun == []) || elem name tests.tests)
         && (test.expr != test.expected)
       then
         [
@@ -238,7 +238,7 @@ rec {
             result = test.expr;
           }
         ]
-      else [ ]) tests));
+      else []) tests));
 
   /*
    Create a test assuming that list elements are `true`.
@@ -288,7 +288,7 @@ rec {
                 (attrNames drv)
               }>"
             )
-          else if [ ] == v
+          else if [] == v
           then pr (const "[]")
           else if isList v
           then pr (l: "[ ${go (head l)}, … ]")
diff --git a/lib/deprecated.nix b/lib/deprecated.nix
index fbd45f3d5..db09545bd 100644
--- a/lib/deprecated.nix
+++ b/lib/deprecated.nix
@@ -22,13 +22,13 @@ with lib.strings; rec {
     arg = (merger init (defaultMergeArg init x));
     # now add the function with composed args already applied to the final attrs
     base = (
-      setAttrMerge "passthru" { } (f arg)
+      setAttrMerge "passthru" {} (f arg)
       (
         z:
           z
           // {
             function = foldArgs merger f arg;
-            args = (lib.attrByPath [ "passthru" "args" ] { } z) // x;
+            args = (lib.attrByPath ["passthru" "args"] {} z) // x;
           }
       )
     );
@@ -52,9 +52,9 @@ with lib.strings; rec {
     if cond
     then val
     else if builtins.isList val
-    then [ ]
+    then []
     else if builtins.isAttrs val
-    then { }
+    then {}
     # else if builtins.isString val then ""
     else if val == true || val == false
     then false
@@ -66,17 +66,17 @@ with lib.strings; rec {
     then true
     else if name == "false"
     then false
-    else if (elem name (attrByPath [ "flags" ] [ ] attrSet))
+    else if (elem name (attrByPath ["flags"] [] attrSet))
     then true
-    else attrByPath [ name ] false attrSet;
+    else attrByPath [name] false attrSet;
 
   # Input : attrSet, [ [name default] ... ], name
   # Output : its value or default.
   getValue = attrSet: argList: name: (
-    attrByPath [ name ] (
+    attrByPath [name] (
       if checkFlag attrSet name
       then true
-      else if argList == [ ]
+      else if argList == []
       then null
       else
         let
@@ -127,19 +127,19 @@ with lib.strings; rec {
   uniqList =
     {
       inputList,
-      acc ? [ ],
+      acc ? [],
     }:
     let
       go = xs: acc:
-        if xs == [ ]
-        then [ ]
+        if xs == []
+        then []
         else
           let
             x = head xs;
             y =
               if elem x acc
-              then [ ]
-              else [ x ];
+              then []
+              else [x];
           in
             y ++ go (tail xs) (y ++ acc);
     in
@@ -148,11 +148,11 @@ with lib.strings; rec {
   uniqListExt =
     {
       inputList,
-      outputList ? [ ],
+      outputList ? [],
       getter ? (x: x),
       compare ? (x: y: x == y),
     }:
-      if inputList == [ ]
+      if inputList == []
       then outputList
       else
         let
@@ -162,8 +162,8 @@ with lib.strings; rec {
             outputList
             ++ (
               if any isX outputList
-              then [ ]
-              else [ x ]
+              then []
+              else [x]
             );
         in
           uniqListExt {
@@ -173,7 +173,7 @@ with lib.strings; rec {
           };
 
   condConcat = name: list: checker:
-    if list == [ ]
+    if list == []
     then name
     else if checker (head list)
     then
@@ -193,7 +193,7 @@ with lib.strings; rec {
     }:
     let
       work = list: doneKeys: result:
-        if list == [ ]
+        if list == []
         then result
         else
           let
@@ -202,18 +202,18 @@ with lib.strings; rec {
           in
             if elem key doneKeys
             then work (tail list) doneKeys result
-            else work (tail list ++ operator x) ([ key ] ++ doneKeys) ([ x ] ++ result);
+            else work (tail list ++ operator x) ([key] ++ doneKeys) ([x] ++ result);
     in
-      work startSet [ ] [ ];
+      work startSet [] [];
 
   innerModifySumArgs = f: x: a: b:
     if b == null
     then (f a b) // x
     else innerModifySumArgs f x (a // b);
-  modifySumArgs = f: x: innerModifySumArgs f x { };
+  modifySumArgs = f: x: innerModifySumArgs f x {};
 
   innerClosePropagation = acc: xs:
-    if xs == [ ]
+    if xs == []
     then acc
     else
       let
@@ -224,27 +224,27 @@ with lib.strings; rec {
         then innerClosePropagation acc ys
         else
           let
-            acc' = [ y ] ++ acc;
+            acc' = [y] ++ acc;
           in
             innerClosePropagation
             acc'
             (
               uniqList {
                 inputList =
-                  (maybeAttrNullable "propagatedBuildInputs" [ ] y)
-                  ++ (maybeAttrNullable "propagatedNativeBuildInputs" [ ] y)
+                  (maybeAttrNullable "propagatedBuildInputs" [] y)
+                  ++ (maybeAttrNullable "propagatedNativeBuildInputs" [] y)
                   ++ ys;
                 acc = acc';
               }
             );
 
-  closePropagation = list: (uniqList { inputList = (innerClosePropagation [ ] list); });
+  closePropagation = list: (uniqList { inputList = (innerClosePropagation [] list); });
 
   # calls a function (f attr value ) for each record item. returns a list
   mapAttrsFlatten = f: r: map (attr: f attr r.${attr}) (attrNames r);
 
   # attribute set containing one attribute
-  nvs = name: value: listToAttrs [ (nameValuePair name value) ];
+  nvs = name: value: listToAttrs [(nameValuePair name value)];
   # adds / replaces an attribute of an attribute set
   setAttr = set: name: v: set // (nvs name v);
 
@@ -279,8 +279,8 @@ with lib.strings; rec {
   # ! deprecated, use mergeAttrByFunc instead
   mergeAttrsNoOverride =
     {
-      mergeLists ? [ "buildInputs" "propagatedBuildInputs" ],
-      overrideSnd ? [ "buildPhase" ],
+      mergeLists ? ["buildInputs" "propagatedBuildInputs"],
+      overrideSnd ? ["buildPhase"],
     }:
       attrs1: attrs2:
         foldr (
@@ -315,10 +315,10 @@ with lib.strings; rec {
   mergeAttrByFunc = x: y: let
     mergeAttrBy2 =
       { mergeAttrBy = lib.mergeAttrs; }
-      // (maybeAttr "mergeAttrBy" { } x)
-      // (maybeAttr "mergeAttrBy" { } y);
+      // (maybeAttr "mergeAttrBy" {} x)
+      // (maybeAttr "mergeAttrBy" {} y);
   in
-    foldr lib.mergeAttrs { } [
+    foldr lib.mergeAttrs {} [
       x
       y
       (
@@ -345,17 +345,17 @@ with lib.strings; rec {
       )
     ];
   mergeAttrsByFuncDefaults = foldl mergeAttrByFunc { inherit mergeAttrBy; };
-  mergeAttrsByFuncDefaultsClean = list: removeAttrs (mergeAttrsByFuncDefaults list) [ "mergeAttrBy" ];
+  mergeAttrsByFuncDefaultsClean = list: removeAttrs (mergeAttrsByFuncDefaults list) ["mergeAttrBy"];
 
   # sane defaults (same name as attr name so that inherit can be used)
   mergeAttrBy =
     # { buildInputs = concatList; [...]; passthru = mergeAttr; [..]; }
     listToAttrs (
       map (n: nameValuePair n lib.concat)
-      [ "nativeBuildInputs" "buildInputs" "propagatedBuildInputs" "configureFlags" "prePhases" "postAll" "patches" ]
+      ["nativeBuildInputs" "buildInputs" "propagatedBuildInputs" "configureFlags" "prePhases" "postAll" "patches"]
     )
-    // listToAttrs (map (n: nameValuePair n lib.mergeAttrs) [ "passthru" "meta" "cfg" "flags" ])
-    // listToAttrs (map (n: nameValuePair n (a: b: "${a}\n${b}")) [ "preConfigure" "postInstall" ]);
+    // listToAttrs (map (n: nameValuePair n lib.mergeAttrs) ["passthru" "meta" "cfg" "flags"])
+    // listToAttrs (map (n: nameValuePair n (a: b: "${a}\n${b}")) ["preConfigure" "postInstall"]);
 
   nixType = x:
     if isAttrs x
diff --git a/lib/fixed-points.nix b/lib/fixed-points.nix
index 58149a9c6..5ced3d25d 100644
--- a/lib/fixed-points.nix
+++ b/lib/fixed-points.nix
@@ -87,7 +87,7 @@ rec {
   # composeManyExtensions : [packageSet -> packageSet -> packageSet] -> packageSet -> packageSet -> packageSet
   #                          ^final        ^prev         ^overrides     ^final        ^prev         ^overrides
   composeManyExtensions =
-    lib.foldr (x: y: composeExtensions x y) (final: prev: { });
+    lib.foldr (x: y: composeExtensions x y) (final: prev: {});
 
   # Create an overridable, recursive attribute set. For example:
   #
diff --git a/lib/generators.nix b/lib/generators.nix
index c5ad54699..c760276b7 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -29,12 +29,12 @@ in
      * The builtin `toString` function has some strange defaults,
      * suitable for bash scripts but not much else.
      */
-    mkValueStringDefault = { }: v: with builtins; let
+    mkValueStringDefault = {}: v: with builtins; let
       err = t: v:
         abort
         (
           "generators.mkValueStringDefault: "
-          + "${t} not supported: ${toPretty { } v}"
+          + "${t} not supported: ${toPretty {} v}"
         );
     in
       if isInt v
@@ -79,7 +79,7 @@ in
      * mkKeyValueDefault {} ":" "f:oo" "bar"
      * > "f\:oo:bar"
      */
-    mkKeyValueDefault = { mkValueString ? mkValueStringDefault { } }: sep: k: v: "${libStr.escape [ sep ] k}${sep}${mkValueString v}";
+    mkKeyValueDefault = { mkValueString ? mkValueStringDefault {} }: sep: k: v: "${libStr.escape [sep] k}${sep}${mkValueString v}";
 
     ## -- FILE FORMAT GENERATORS --
 
@@ -90,7 +90,7 @@ in
      */
     toKeyValue =
       {
-        mkKeyValue ? mkKeyValueDefault { } "=",
+        mkKeyValue ? mkKeyValueDefault {} "=",
         listsAsDuplicateKeys ? false,
       }:
       let

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