about summary refs log tree commit diff
path: root/third_party/nix/src/nix-instantiate/nix-instantiate.cc
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/nix-instantiate/nix-instantiate.cc')
-rw-r--r--third_party/nix/src/nix-instantiate/nix-instantiate.cc60
1 files changed, 32 insertions, 28 deletions
diff --git a/third_party/nix/src/nix-instantiate/nix-instantiate.cc b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
index 20dcd7f42df8..05f481906b28 100644
--- a/third_party/nix/src/nix-instantiate/nix-instantiate.cc
+++ b/third_party/nix/src/nix-instantiate/nix-instantiate.cc
@@ -40,15 +40,16 @@ void processExpr(EvalState& state, const Strings& attrPaths, bool parseOnly,
     PathSet context;
     if (evalOnly) {
       Value vRes;
-      if (autoArgs.empty())
+      if (autoArgs.empty()) {
         vRes = v;
-      else
+      } else {
         state.autoCallFunction(autoArgs, v, vRes);
-      if (output == okXML)
+      }
+      if (output == okXML) {
         printValueAsXML(state, strict, location, vRes, std::cout, context);
-      else if (output == okJSON)
+      } else if (output == okJSON) {
         printValueAsJSON(state, strict, vRes, std::cout, context);
-      else {
+      } else {
         if (strict) {
           state.forceValueDeep(vRes);
         }
@@ -62,21 +63,23 @@ void processExpr(EvalState& state, const Strings& attrPaths, bool parseOnly,
 
         /* What output do we want? */
         string outputName = i.queryOutputName();
-        if (outputName == "")
+        if (outputName == "") {
           throw Error(
               format("derivation '%1%' lacks an 'outputName' attribute ") %
               drvPath);
+        }
 
-        if (gcRoot == "")
+        if (gcRoot == "") {
           printGCWarning();
-        else {
+        } else {
           Path rootName = indirectRoot ? absPath(gcRoot) : gcRoot;
           if (++rootNr > 1) {
             rootName += "-" + std::to_string(rootNr);
           }
           auto store2 = state.store.dynamic_pointer_cast<LocalFSStore>();
-          if (store2)
+          if (store2) {
             drvPath = store2->addPermRoot(drvPath, rootName, indirectRoot);
+          }
         }
         std::cout << format("%1%%2%\n") % drvPath %
                          (outputName != "out" ? "!" + outputName : "");
@@ -106,44 +109,45 @@ static int _main(int argc, char** argv) {
 
     MyArgs myArgs(baseNameOf(argv[0]),
                   [&](Strings::iterator& arg, const Strings::iterator& end) {
-                    if (*arg == "--help")
+                    if (*arg == "--help") {
                       showManPage("nix-instantiate");
-                    else if (*arg == "--version")
+                    } else if (*arg == "--version") {
                       printVersion("nix-instantiate");
-                    else if (*arg == "-")
+                    } else if (*arg == "-") {
                       readStdin = true;
-                    else if (*arg == "--expr" || *arg == "-E")
+                    } else if (*arg == "--expr" || *arg == "-E") {
                       fromArgs = true;
-                    else if (*arg == "--eval" || *arg == "--eval-only")
+                    } else if (*arg == "--eval" || *arg == "--eval-only") {
                       evalOnly = true;
-                    else if (*arg == "--read-write-mode")
+                    } else if (*arg == "--read-write-mode") {
                       wantsReadWrite = true;
-                    else if (*arg == "--parse" || *arg == "--parse-only")
+                    } else if (*arg == "--parse" || *arg == "--parse-only") {
                       parseOnly = evalOnly = true;
-                    else if (*arg == "--find-file")
+                    } else if (*arg == "--find-file") {
                       findFile = true;
-                    else if (*arg == "--attr" || *arg == "-A")
+                    } else if (*arg == "--attr" || *arg == "-A") {
                       attrPaths.push_back(getArg(*arg, arg, end));
-                    else if (*arg == "--add-root")
+                    } else if (*arg == "--add-root") {
                       gcRoot = getArg(*arg, arg, end);
-                    else if (*arg == "--indirect")
+                    } else if (*arg == "--indirect") {
                       indirectRoot = true;
-                    else if (*arg == "--xml")
+                    } else if (*arg == "--xml") {
                       outputKind = okXML;
-                    else if (*arg == "--json")
+                    } else if (*arg == "--json") {
                       outputKind = okJSON;
-                    else if (*arg == "--no-location")
+                    } else if (*arg == "--no-location") {
                       xmlOutputSourceLocation = false;
-                    else if (*arg == "--strict")
+                    } else if (*arg == "--strict") {
                       strict = true;
-                    else if (*arg == "--repair")
+                    } else if (*arg == "--repair") {
                       repair = Repair;
-                    else if (*arg == "--dry-run")
+                    } else if (*arg == "--dry-run") {
                       settings.readOnlyMode = true;
-                    else if (*arg != "" && arg->at(0) == '-')
+                    } else if (*arg != "" && arg->at(0) == '-') {
                       return false;
-                    else
+                    } else {
                       files.push_back(*arg);
+                    }
                     return true;
                   });