about summary refs log tree commit diff
path: root/third_party/nix/src/nix/upgrade-nix.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-19T19·47+0100
committerVincent Ambo <tazjin@google.com>2020-05-19T19·51+0100
commit39087321811e81e26a1a47d6967df1088dcf0e95 (patch)
tree57110be423eeb7869e9960466f4b17c0ea7cd961 /third_party/nix/src/nix/upgrade-nix.cc
parentcf40d08908ede4061eb15513b770c98877844b8b (diff)
style(3p/nix): Final act in the brace-wrapping saga r/777
This last change set was generated by a full clang-tidy run (including
compilation):

    clang-tidy -p ~/projects/nix-build/ \
      -checks=-*,readability-braces-around-statements -fix src/*/*.cc

Actually running clang-tidy requires some massaging to make it play
nice with Nix + meson, I'll be adding a wrapper or something for that soon.
Diffstat (limited to 'third_party/nix/src/nix/upgrade-nix.cc')
-rw-r--r--third_party/nix/src/nix/upgrade-nix.cc18
1 files changed, 12 insertions, 6 deletions
diff --git a/third_party/nix/src/nix/upgrade-nix.cc b/third_party/nix/src/nix/upgrade-nix.cc
index 277d761ec581..dd11da0087c7 100644
--- a/third_party/nix/src/nix/upgrade-nix.cc
+++ b/third_party/nix/src/nix/upgrade-nix.cc
@@ -80,8 +80,9 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand {
       LOG(INFO) << "verifying that '" << storePath << "' works...";
       auto program = storePath + "/bin/nix-env";
       auto s = runProgram(program, false, {"--version"});
-      if (s.find("Nix") == std::string::npos)
+      if (s.find("Nix") == std::string::npos) {
         throw Error("could not verify that '%s' works", program);
+      }
     }
 
     {
@@ -99,15 +100,17 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand {
   Path getProfileDir(ref<Store> store) {
     Path where;
 
-    for (auto& dir : tokenizeString<Strings>(getEnv("PATH"), ":"))
+    for (auto& dir : tokenizeString<Strings>(getEnv("PATH"), ":")) {
       if (pathExists(dir + "/nix-env")) {
         where = dir;
         break;
       }
+    }
 
-    if (where == "")
+    if (where == "") {
       throw Error(
           "couldn't figure out how Nix is installed, so I can't upgrade it");
+    }
 
     LOG(INFO) << "found Nix in '" << where << "'";
 
@@ -119,19 +122,22 @@ struct CmdUpgradeNix : MixDryRun, StoreCommand {
 
     // Resolve profile to /nix/var/nix/profiles/<name> link.
     while (canonPath(profileDir).find("/profiles/") == std::string::npos &&
-           isLink(profileDir))
+           isLink(profileDir)) {
       profileDir = readLink(profileDir);
+    }
 
     LOG(INFO) << "found profile '" << profileDir << "'";
 
     Path userEnv = canonPath(profileDir, true);
 
-    if (baseNameOf(where) != "bin" || !hasSuffix(userEnv, "user-environment"))
+    if (baseNameOf(where) != "bin" || !hasSuffix(userEnv, "user-environment")) {
       throw Error("directory '%s' does not appear to be part of a Nix profile",
                   where);
+    }
 
-    if (!store->isValidPath(userEnv))
+    if (!store->isValidPath(userEnv)) {
       throw Error("directory '%s' is not in the Nix store", userEnv);
+    }
 
     return profileDir;
   }