about summary refs log tree commit diff
diff options
context:
space:
mode:
authorKane York <kanepyork@gmail.com>2020-11-28T00·31-0800
committerkanepyork <rikingcoding@gmail.com>2020-11-28T00·59+0000
commit516c046ed984ba74da9a36f21e356dae9e227ca3 (patch)
tree14daaf1ff037440025caa12ca60888b9cefbb3bb
parent363dbeae95ce46be2b716506de90717998391a57 (diff)
refactor(tvix): remove all 'using namespace' from nix command r/1949
clang-tidy: google-build-using-namespace
Change-Id: I07ea10b03a6d9582c0508747698038f7106e8f63
Reviewed-on: https://cl.tvl.fyi/c/depot/+/2181
Tested-by: BuildkiteCI
Reviewed-by: glittershark <grfn@gws.fyi>
-rw-r--r--third_party/nix/src/nix/add-to-store.cc6
-rw-r--r--third_party/nix/src/nix/build.cc6
-rw-r--r--third_party/nix/src/nix/cat.cc8
-rw-r--r--third_party/nix/src/nix/copy.cc6
-rw-r--r--third_party/nix/src/nix/doctor.cc8
-rw-r--r--third_party/nix/src/nix/dump-path.cc6
-rw-r--r--third_party/nix/src/nix/edit.cc6
-rw-r--r--third_party/nix/src/nix/eval.cc6
-rw-r--r--third_party/nix/src/nix/hash.cc4
-rw-r--r--third_party/nix/src/nix/log.cc6
-rw-r--r--third_party/nix/src/nix/ls.cc8
-rw-r--r--third_party/nix/src/nix/optimise-store.cc6
-rw-r--r--third_party/nix/src/nix/path-info.cc6
-rw-r--r--third_party/nix/src/nix/ping-store.cc6
-rw-r--r--third_party/nix/src/nix/run.cc51
-rw-r--r--third_party/nix/src/nix/search.cc8
-rw-r--r--third_party/nix/src/nix/show-config.cc6
-rw-r--r--third_party/nix/src/nix/show-derivation.cc6
-rw-r--r--third_party/nix/src/nix/sigs.cc7
-rw-r--r--third_party/nix/src/nix/upgrade-nix.cc6
-rw-r--r--third_party/nix/src/nix/verify.cc6
-rw-r--r--third_party/nix/src/nix/why-depends.cc8
22 files changed, 96 insertions, 90 deletions
diff --git a/third_party/nix/src/nix/add-to-store.cc b/third_party/nix/src/nix/add-to-store.cc
index 34f6d03963..53641f120e 100644
--- a/third_party/nix/src/nix/add-to-store.cc
+++ b/third_party/nix/src/nix/add-to-store.cc
@@ -3,8 +3,7 @@
 #include "libutil/archive.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdAddToStore final : MixDryRun, StoreCommand {
   Path path;
   std::optional<std::string> namePart;
@@ -47,5 +46,6 @@ struct CmdAddToStore final : MixDryRun, StoreCommand {
     std::cout << fmt("%s\n", info.path);
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdAddToStore>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdAddToStore>());
diff --git a/third_party/nix/src/nix/build.cc b/third_party/nix/src/nix/build.cc
index b0e8feefd3..3fe74b7ffd 100644
--- a/third_party/nix/src/nix/build.cc
+++ b/third_party/nix/src/nix/build.cc
@@ -3,8 +3,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdBuild final : MixDryRun, InstallablesCommand {
   Path outLink = "result";
 
@@ -64,5 +63,6 @@ struct CmdBuild final : MixDryRun, InstallablesCommand {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdBuild>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdBuild>());
diff --git a/third_party/nix/src/nix/cat.cc b/third_party/nix/src/nix/cat.cc
index 9ead9a6ff6..7788707eae 100644
--- a/third_party/nix/src/nix/cat.cc
+++ b/third_party/nix/src/nix/cat.cc
@@ -3,8 +3,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct MixCat : virtual Args {
   std::string path;
 
@@ -51,6 +50,7 @@ struct CmdCatNar final : StoreCommand, MixCat {
     cat(makeNarAccessor(make_ref<std::string>(readFile(narPath))));
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdCatStore>());
-static RegisterCommand r2(make_ref<CmdCatNar>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdCatStore>());
+static nix::RegisterCommand r2(nix::make_ref<nix::CmdCatNar>());
diff --git a/third_party/nix/src/nix/copy.cc b/third_party/nix/src/nix/copy.cc
index ec25d0fc5a..75c85698d1 100644
--- a/third_party/nix/src/nix/copy.cc
+++ b/third_party/nix/src/nix/copy.cc
@@ -6,8 +6,7 @@
 #include "libutil/thread-pool.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdCopy final : StorePathsCommand {
   std::string srcUri, dstUri;
 
@@ -82,5 +81,6 @@ struct CmdCopy final : StorePathsCommand {
               NoRepair, checkSigs, substitute);
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdCopy>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdCopy>());
diff --git a/third_party/nix/src/nix/doctor.cc b/third_party/nix/src/nix/doctor.cc
index e65ca69f6b..d0b4c2b588 100644
--- a/third_party/nix/src/nix/doctor.cc
+++ b/third_party/nix/src/nix/doctor.cc
@@ -8,9 +8,8 @@
 #include "libstore/worker-protocol.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
-std::string formatProtocol(unsigned int proto) {
+namespace nix {
+static std::string formatProtocol(unsigned int proto) {
   if (proto != 0u) {
     auto major = GET_PROTOCOL_MAJOR(proto) >> 8;
     auto minor = GET_PROTOCOL_MINOR(proto);
@@ -138,5 +137,6 @@ struct CmdDoctor final : StoreCommand {
     return true;
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdDoctor>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdDoctor>());
diff --git a/third_party/nix/src/nix/dump-path.cc b/third_party/nix/src/nix/dump-path.cc
index 4ca5f1bc02..1d0a996e56 100644
--- a/third_party/nix/src/nix/dump-path.cc
+++ b/third_party/nix/src/nix/dump-path.cc
@@ -1,8 +1,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdDumpPath final : StorePathCommand {
   std::string name() override { return "dump-path"; }
 
@@ -24,5 +23,6 @@ struct CmdDumpPath final : StorePathCommand {
     sink.flush();
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdDumpPath>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdDumpPath>());
diff --git a/third_party/nix/src/nix/edit.cc b/third_party/nix/src/nix/edit.cc
index b5369e4a8a..04c67acb94 100644
--- a/third_party/nix/src/nix/edit.cc
+++ b/third_party/nix/src/nix/edit.cc
@@ -7,8 +7,7 @@
 #include "libmain/shared.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdEdit final : InstallableCommand {
   std::string name() override { return "edit"; }
 
@@ -71,5 +70,6 @@ struct CmdEdit final : InstallableCommand {
     throw SysError("cannot run editor '%s'", editor);
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdEdit>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdEdit>());
diff --git a/third_party/nix/src/nix/eval.cc b/third_party/nix/src/nix/eval.cc
index a78f5b34fa..72fcbd8271 100644
--- a/third_party/nix/src/nix/eval.cc
+++ b/third_party/nix/src/nix/eval.cc
@@ -7,8 +7,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdEval final : MixJSON, InstallableCommand {
   bool raw = false;
 
@@ -52,5 +51,6 @@ struct CmdEval final : MixJSON, InstallableCommand {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdEval>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdEval>());
diff --git a/third_party/nix/src/nix/hash.cc b/third_party/nix/src/nix/hash.cc
index a40f7b4c85..4fb262f1a8 100644
--- a/third_party/nix/src/nix/hash.cc
+++ b/third_party/nix/src/nix/hash.cc
@@ -4,8 +4,7 @@
 #include "nix/command.hh"
 #include "nix/legacy.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdHash final : Command {
   enum Mode { mFile, mPath };
   Mode mode;
@@ -150,3 +149,4 @@ static int compatNixHash(int argc, char** argv) {
 }
 
 static RegisterLegacyCommand s1("nix-hash", compatNixHash);
+}  // namespace nix
diff --git a/third_party/nix/src/nix/log.cc b/third_party/nix/src/nix/log.cc
index 623d16e5d2..84207d8576 100644
--- a/third_party/nix/src/nix/log.cc
+++ b/third_party/nix/src/nix/log.cc
@@ -5,8 +5,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdLog final : InstallableCommand {
   CmdLog() = default;
 
@@ -59,5 +58,6 @@ struct CmdLog final : InstallableCommand {
     throw Error("build log of '%s' is not available", installable->what());
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdLog>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdLog>());
diff --git a/third_party/nix/src/nix/ls.cc b/third_party/nix/src/nix/ls.cc
index d6ff1aaf81..1da722babb 100644
--- a/third_party/nix/src/nix/ls.cc
+++ b/third_party/nix/src/nix/ls.cc
@@ -5,8 +5,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct MixLs : virtual Args, MixJSON {
   std::string path;
 
@@ -132,6 +131,7 @@ struct CmdLsNar final : Command, MixLs {
     list(makeNarAccessor(make_ref<std::string>(readFile(narPath, true))));
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdLsStore>());
-static RegisterCommand r2(make_ref<CmdLsNar>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdLsStore>());
+static nix::RegisterCommand r2(nix::make_ref<nix::CmdLsNar>());
diff --git a/third_party/nix/src/nix/optimise-store.cc b/third_party/nix/src/nix/optimise-store.cc
index 1b33ea3ec2..ceb53aa77b 100644
--- a/third_party/nix/src/nix/optimise-store.cc
+++ b/third_party/nix/src/nix/optimise-store.cc
@@ -4,8 +4,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdOptimiseStore final : StoreCommand {
   CmdOptimiseStore() = default;
 
@@ -23,5 +22,6 @@ struct CmdOptimiseStore final : StoreCommand {
 
   void run(ref<Store> store) override { store->optimiseStore(); }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdOptimiseStore>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdOptimiseStore>());
diff --git a/third_party/nix/src/nix/path-info.cc b/third_party/nix/src/nix/path-info.cc
index 300a588a2e..fcf060d50d 100644
--- a/third_party/nix/src/nix/path-info.cc
+++ b/third_party/nix/src/nix/path-info.cc
@@ -7,8 +7,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdPathInfo final : StorePathsCommand, MixJSON {
   bool showSize = false;
   bool showClosureSize = false;
@@ -129,5 +128,6 @@ struct CmdPathInfo final : StorePathsCommand, MixJSON {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdPathInfo>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdPathInfo>());
diff --git a/third_party/nix/src/nix/ping-store.cc b/third_party/nix/src/nix/ping-store.cc
index 78a79b037b..4a33486bf8 100644
--- a/third_party/nix/src/nix/ping-store.cc
+++ b/third_party/nix/src/nix/ping-store.cc
@@ -2,8 +2,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdPingStore final : StoreCommand {
   std::string name() override { return "ping-store"; }
 
@@ -21,5 +20,6 @@ struct CmdPingStore final : StoreCommand {
 
   void run(ref<Store> store) override { store->connect(); }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdPingStore>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdPingStore>());
diff --git a/third_party/nix/src/nix/run.cc b/third_party/nix/src/nix/run.cc
index 06c95f856f..b3b54f300b 100644
--- a/third_party/nix/src/nix/run.cc
+++ b/third_party/nix/src/nix/run.cc
@@ -13,10 +13,10 @@
 #include "libutil/finally.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+// note: exported in header file
 std::string chrootHelperName = "__run_in_chroot";
 
+namespace nix {
 struct CmdRun final : InstallablesCommand {
   std::vector<std::string> command = {"bash"};
   StringSet keep, unset;
@@ -187,13 +187,14 @@ struct CmdRun final : InstallablesCommand {
 };
 
 static RegisterCommand r1(make_ref<CmdRun>());
+}  // namespace nix
 
 void chrootHelper(int argc, char** argv) {
   int p = 1;
   std::string storeDir = argv[p++];
   std::string realStoreDir = argv[p++];
   std::string cmd = argv[p++];
-  Strings args;
+  nix::Strings args;
   while (p < argc) {
     args.push_back(argv[p++]);
   }
@@ -206,7 +207,7 @@ void chrootHelper(int argc, char** argv) {
     /* Try with just CLONE_NEWNS in case user namespaces are
        specifically disabled. */
     if (unshare(CLONE_NEWNS) == -1) {
-      throw SysError("setting up a private mount namespace");
+      throw nix::SysError("setting up a private mount namespace");
     }
   }
 
@@ -217,65 +218,65 @@ void chrootHelper(int argc, char** argv) {
      but that doesn't work in a user namespace yet (Ubuntu has a
      patch for this:
      https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1478578). */
-  if (!pathExists(storeDir)) {
+  if (!nix::pathExists(storeDir)) {
     // FIXME: Use overlayfs?
 
-    Path tmpDir = createTempDir();
+    nix::Path tmpDir = nix::createTempDir();
 
-    createDirs(tmpDir + storeDir);
+    nix::createDirs(tmpDir + storeDir);
 
     if (mount(realStoreDir.c_str(), (tmpDir + storeDir).c_str(), "", MS_BIND,
               nullptr) == -1) {
-      throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
+      throw nix::SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
     }
 
-    for (const auto& entry : readDirectory("/")) {
+    for (const auto& entry : nix::readDirectory("/")) {
       auto src = "/" + entry.name;
-      auto st = lstat(src);
+      auto st = nix::lstat(src);
       if (!S_ISDIR(st.st_mode)) {
         continue;
       }
-      Path dst = tmpDir + "/" + entry.name;
-      if (pathExists(dst)) {
+      nix::Path dst = tmpDir + "/" + entry.name;
+      if (nix::pathExists(dst)) {
         continue;
       }
       if (mkdir(dst.c_str(), 0700) == -1) {
-        throw SysError("creating directory '%s'", dst);
+        throw nix::SysError("creating directory '%s'", dst);
       }
       if (mount(src.c_str(), dst.c_str(), "", MS_BIND | MS_REC, nullptr) ==
           -1) {
-        throw SysError("mounting '%s' on '%s'", src, dst);
+        throw nix::SysError("mounting '%s' on '%s'", src, dst);
       }
     }
 
     char* cwd = getcwd(nullptr, 0);
     if (cwd == nullptr) {
-      throw SysError("getting current directory");
+      throw nix::SysError("getting current directory");
     }
-    Finally freeCwd([&]() { free(cwd); });
+    ::Finally freeCwd([&]() { free(cwd); });
 
     if (chroot(tmpDir.c_str()) == -1) {
-      throw SysError(format("chrooting into '%s'") % tmpDir);
+      throw nix::SysError(nix::format("chrooting into '%s'") % tmpDir);
     }
 
     if (chdir(cwd) == -1) {
-      throw SysError(format("chdir to '%s' in chroot") % cwd);
+      throw nix::SysError(nix::format("chdir to '%s' in chroot") % cwd);
     }
   } else if (mount(realStoreDir.c_str(), storeDir.c_str(), "", MS_BIND,
                    nullptr) == -1) {
-    throw SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
+    throw nix::SysError("mounting '%s' on '%s'", realStoreDir, storeDir);
   }
 
-  writeFile("/proc/self/setgroups", "deny");
-  writeFile("/proc/self/uid_map", fmt("%d %d %d", uid, uid, 1));
-  writeFile("/proc/self/gid_map", fmt("%d %d %d", gid, gid, 1));
+  nix::writeFile("/proc/self/setgroups", "deny");
+  nix::writeFile("/proc/self/uid_map", nix::fmt("%d %d %d", uid, uid, 1));
+  nix::writeFile("/proc/self/gid_map", nix::fmt("%d %d %d", gid, gid, 1));
 
-  execvp(cmd.c_str(), stringsToCharPtrs(args).data());
+  execvp(cmd.c_str(), nix::stringsToCharPtrs(args).data());
 
-  throw SysError("unable to exec '%s'", cmd);
+  throw nix::SysError("unable to exec '%s'", cmd);
 
 #else
-  throw Error(
+  throw nix::Error(
       "mounting the Nix store on '%s' is not supported on this platform",
       storeDir);
 #endif
diff --git a/third_party/nix/src/nix/search.cc b/third_party/nix/src/nix/search.cc
index 9db5b3d103..5a6bae6a11 100644
--- a/third_party/nix/src/nix/search.cc
+++ b/third_party/nix/src/nix/search.cc
@@ -14,8 +14,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace {
 std::string wrap(const std::string& prefix, const std::string& s) {
   return prefix + s + ANSI_NORMAL;
 }
@@ -26,7 +25,9 @@ std::string hilite(const std::string& s, const std::smatch& m,
                    : std::string(m.prefix()) + ANSI_RED + std::string(m.str()) +
                          postfix + std::string(m.suffix());
 }
+}  // namespace
 
+namespace nix {
 struct CmdSearch final : SourceExprCommand, MixJSON {
   std::vector<std::string> res;
 
@@ -270,5 +271,6 @@ struct CmdSearch final : SourceExprCommand, MixJSON {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdSearch>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdSearch>());
diff --git a/third_party/nix/src/nix/show-config.cc b/third_party/nix/src/nix/show-config.cc
index 56448f9d60..fd92e481e8 100644
--- a/third_party/nix/src/nix/show-config.cc
+++ b/third_party/nix/src/nix/show-config.cc
@@ -4,8 +4,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdShowConfig final : Command, MixJSON {
   CmdShowConfig() = default;
 
@@ -27,5 +26,6 @@ struct CmdShowConfig final : Command, MixJSON {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdShowConfig>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdShowConfig>());
diff --git a/third_party/nix/src/nix/show-derivation.cc b/third_party/nix/src/nix/show-derivation.cc
index 51c7ba9c29..efe554710f 100644
--- a/third_party/nix/src/nix/show-derivation.cc
+++ b/third_party/nix/src/nix/show-derivation.cc
@@ -7,8 +7,7 @@
 #include "libutil/json.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdShowDerivation final : InstallablesCommand {
   bool recursive = false;
 
@@ -109,5 +108,6 @@ struct CmdShowDerivation final : InstallablesCommand {
     std::cout << "\n";
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdShowDerivation>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdShowDerivation>());
diff --git a/third_party/nix/src/nix/sigs.cc b/third_party/nix/src/nix/sigs.cc
index 21d14bffac..cc42613d07 100644
--- a/third_party/nix/src/nix/sigs.cc
+++ b/third_party/nix/src/nix/sigs.cc
@@ -7,8 +7,7 @@
 #include "libutil/thread-pool.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdCopySigs final : StorePathsCommand {
   Strings substituterUris;
 
@@ -97,7 +96,7 @@ struct CmdCopySigs final : StorePathsCommand {
   }
 };
 
-static RegisterCommand r1(make_ref<CmdCopySigs>());
+static nix::RegisterCommand r1(make_ref<CmdCopySigs>());
 
 struct CmdSignPaths final : StorePathsCommand {
   Path secretKeyFile;
@@ -143,3 +142,5 @@ struct CmdSignPaths final : StorePathsCommand {
 };
 
 static RegisterCommand r3(make_ref<CmdSignPaths>());
+
+}  // namespace nix
diff --git a/third_party/nix/src/nix/upgrade-nix.cc b/third_party/nix/src/nix/upgrade-nix.cc
index 77e284afba..c7f654d648 100644
--- a/third_party/nix/src/nix/upgrade-nix.cc
+++ b/third_party/nix/src/nix/upgrade-nix.cc
@@ -11,8 +11,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdUpgradeNix final : MixDryRun, StoreCommand {
   Path profileDir;
   std::string storePathsUrl =
@@ -163,5 +162,6 @@ struct CmdUpgradeNix final : MixDryRun, StoreCommand {
     return state->forceString(*v2);
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdUpgradeNix>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdUpgradeNix>());
diff --git a/third_party/nix/src/nix/verify.cc b/third_party/nix/src/nix/verify.cc
index 6552e3d1a7..7de46f2a9c 100644
--- a/third_party/nix/src/nix/verify.cc
+++ b/third_party/nix/src/nix/verify.cc
@@ -8,8 +8,7 @@
 #include "libutil/thread-pool.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace nix {
 struct CmdVerify final : StorePathsCommand {
   bool noContents = false;
   bool noTrust = false;
@@ -167,5 +166,6 @@ struct CmdVerify final : StorePathsCommand {
                (failed != 0u ? 4 : 0));
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdVerify>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdVerify>());
diff --git a/third_party/nix/src/nix/why-depends.cc b/third_party/nix/src/nix/why-depends.cc
index e18314e7fd..954d619ef3 100644
--- a/third_party/nix/src/nix/why-depends.cc
+++ b/third_party/nix/src/nix/why-depends.cc
@@ -7,8 +7,7 @@
 #include "libstore/store-api.hh"
 #include "nix/command.hh"
 
-using namespace nix;
-
+namespace {
 static std::string hilite(const std::string& s, size_t pos, size_t len,
                           const std::string& colour = ANSI_RED) {
   return std::string(s, 0, pos) + colour + std::string(s, pos, len) +
@@ -22,7 +21,9 @@ static std::string filterPrintable(const std::string& s) {
   }
   return res;
 }
+}  // namespace
 
+namespace nix {
 struct CmdWhyDepends final : SourceExprCommand {
   std::string _package, _dependency;
   bool all = false;
@@ -263,5 +264,6 @@ struct CmdWhyDepends final : SourceExprCommand {
     }
   }
 };
+}  // namespace nix
 
-static RegisterCommand r1(make_ref<CmdWhyDepends>());
+static nix::RegisterCommand r1(nix::make_ref<nix::CmdWhyDepends>());