about summary refs log tree commit diff
path: root/third_party/nix/src/libstore
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
committerVincent Ambo <tazjin@google.com>2020-05-24T21·29+0100
commit838f86b0fd880b26539664140f04e5d16669dad8 (patch)
treec8fee2f0c136fbe5bb0735604e2f04d5b02698ba /third_party/nix/src/libstore
parentf30b2e610d9e612504a9f6460e0cc83413b80aeb (diff)
style(3p/nix): Remove 'using std::*' from types.hh r/840
It is considered bad form to use things from includes in headers, as
these directives propagate to everywhere else and can make it
confusing.

types.hh (which is includes almost literally everywhere) had some of
these directives, which this commit removes.
Diffstat (limited to 'third_party/nix/src/libstore')
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.cc5
-rw-r--r--third_party/nix/src/libstore/binary-cache-store.hh6
-rw-r--r--third_party/nix/src/libstore/build.cc131
-rw-r--r--third_party/nix/src/libstore/builtins/buildenv.cc4
-rw-r--r--third_party/nix/src/libstore/builtins/fetchurl.cc2
-rw-r--r--third_party/nix/src/libstore/crypto.cc8
-rw-r--r--third_party/nix/src/libstore/derivations.cc60
-rw-r--r--third_party/nix/src/libstore/derivations.hh28
-rw-r--r--third_party/nix/src/libstore/download.cc29
-rw-r--r--third_party/nix/src/libstore/download.hh2
-rw-r--r--third_party/nix/src/libstore/gc.cc38
-rw-r--r--third_party/nix/src/libstore/globals.cc2
-rw-r--r--third_party/nix/src/libstore/globals.hh2
-rw-r--r--third_party/nix/src/libstore/http-binary-cache-store.cc2
-rw-r--r--third_party/nix/src/libstore/legacy-ssh-store.cc10
-rw-r--r--third_party/nix/src/libstore/local-fs-store.cc11
-rw-r--r--third_party/nix/src/libstore/local-store.cc43
-rw-r--r--third_party/nix/src/libstore/local-store.hh14
-rw-r--r--third_party/nix/src/libstore/machines.cc24
-rw-r--r--third_party/nix/src/libstore/machines.hh14
-rw-r--r--third_party/nix/src/libstore/nar-accessor.cc6
-rw-r--r--third_party/nix/src/libstore/nar-info.cc2
-rw-r--r--third_party/nix/src/libstore/optimise-store.cc4
-rw-r--r--third_party/nix/src/libstore/pathlocks.cc4
-rw-r--r--third_party/nix/src/libstore/pathlocks.hh6
-rw-r--r--third_party/nix/src/libstore/profiles.cc22
-rw-r--r--third_party/nix/src/libstore/profiles.hh8
-rw-r--r--third_party/nix/src/libstore/references.cc30
-rw-r--r--third_party/nix/src/libstore/remote-store.cc14
-rw-r--r--third_party/nix/src/libstore/remote-store.hh6
-rw-r--r--third_party/nix/src/libstore/s3-binary-cache-store.cc7
-rw-r--r--third_party/nix/src/libstore/sqlite.cc2
-rw-r--r--third_party/nix/src/libstore/store-api.cc64
-rw-r--r--third_party/nix/src/libstore/store-api.hh52
34 files changed, 336 insertions, 326 deletions
diff --git a/third_party/nix/src/libstore/binary-cache-store.cc b/third_party/nix/src/libstore/binary-cache-store.cc
index 487c12b5313e..37d1c1a440a2 100644
--- a/third_party/nix/src/libstore/binary-cache-store.cc
+++ b/third_party/nix/src/libstore/binary-cache-store.cc
@@ -289,7 +289,7 @@ void BinaryCacheStore::queryPathInfoUncached(
           }});
 }
 
-Path BinaryCacheStore::addToStore(const string& name, const Path& srcPath,
+Path BinaryCacheStore::addToStore(const std::string& name, const Path& srcPath,
                                   bool recursive, HashType hashAlgo,
                                   PathFilter& filter, RepairFlag repair) {
   // FIXME: some cut&paste from LocalStore::addToStore().
@@ -316,7 +316,8 @@ Path BinaryCacheStore::addToStore(const string& name, const Path& srcPath,
   return info.path;
 }
 
-Path BinaryCacheStore::addTextToStore(const string& name, const string& s,
+Path BinaryCacheStore::addTextToStore(const std::string& name,
+                                      const std::string& s,
                                       const PathSet& references,
                                       RepairFlag repair) {
   ValidPathInfo info;
diff --git a/third_party/nix/src/libstore/binary-cache-store.hh b/third_party/nix/src/libstore/binary-cache-store.hh
index f5bd66bbd6e1..b8e1ccabf264 100644
--- a/third_party/nix/src/libstore/binary-cache-store.hh
+++ b/third_party/nix/src/libstore/binary-cache-store.hh
@@ -74,7 +74,7 @@ class BinaryCacheStore : public Store {
       const Path& path,
       Callback<std::shared_ptr<ValidPathInfo>> callback) noexcept override;
 
-  Path queryPathFromHashPart(const string& hashPart) override {
+  Path queryPathFromHashPart(const std::string& hashPart) override {
     unsupported("queryPathFromHashPart");
   }
 
@@ -84,11 +84,11 @@ class BinaryCacheStore : public Store {
                   RepairFlag repair, CheckSigsFlag checkSigs,
                   std::shared_ptr<FSAccessor> accessor) override;
 
-  Path addToStore(const string& name, const Path& srcPath, bool recursive,
+  Path addToStore(const std::string& name, const Path& srcPath, bool recursive,
                   HashType hashAlgo, PathFilter& filter,
                   RepairFlag repair) override;
 
-  Path addTextToStore(const string& name, const string& s,
+  Path addTextToStore(const std::string& name, const std::string& s,
                       const PathSet& references, RepairFlag repair) override;
 
   void narFromPath(const Path& path, Sink& sink) override;
diff --git a/third_party/nix/src/libstore/build.cc b/third_party/nix/src/libstore/build.cc
index 266cedc096ad..49204a72a8cd 100644
--- a/third_party/nix/src/libstore/build.cc
+++ b/third_party/nix/src/libstore/build.cc
@@ -73,9 +73,7 @@
 
 namespace nix {
 
-using std::map;
-
-static string pathNullDevice = "/dev/null";
+static std::string pathNullDevice = "/dev/null";
 
 /* Forward definition. */
 class Worker;
@@ -92,11 +90,11 @@ struct CompareGoalPtrs {
 };
 
 /* Set of goals. */
-typedef set<GoalPtr, CompareGoalPtrs> Goals;
-using WeakGoals = list<WeakGoalPtr>;
+typedef std::set<GoalPtr, CompareGoalPtrs> Goals;
+using WeakGoals = std::list<WeakGoalPtr>;
 
 /* A map of paths to goals (and the other way around). */
-typedef map<Path, WeakGoalPtr> WeakGoalMap;
+typedef std::map<Path, WeakGoalPtr> WeakGoalMap;
 
 class Goal : public std::enable_shared_from_this<Goal> {
  public:
@@ -131,7 +129,7 @@ class Goal : public std::enable_shared_from_this<Goal> {
   unsigned int nrIncompleteClosure;
 
   /* Name of this goal for debugging purposes. */
-  string name;
+  std::string name;
 
   /* Whether the goal is finished. */
   ExitCode exitCode;
@@ -150,13 +148,13 @@ class Goal : public std::enable_shared_from_this<Goal> {
 
   virtual void waiteeDone(GoalPtr waitee, ExitCode result);
 
-  virtual void handleChildOutput(int fd, const string& data) { abort(); }
+  virtual void handleChildOutput(int fd, const std::string& data) { abort(); }
 
   virtual void handleEOF(int fd) { abort(); }
 
   void trace(const FormatOrString& fs);
 
-  string getName() { return name; }
+  std::string getName() { return name; }
 
   ExitCode getExitCode() { return exitCode; }
 
@@ -165,15 +163,15 @@ class Goal : public std::enable_shared_from_this<Goal> {
      by the worker (important!), etc. */
   virtual void timedOut() = 0;
 
-  virtual string key() = 0;
+  virtual std::string key() = 0;
 
  protected:
   virtual void amDone(ExitCode result);
 };
 
 bool CompareGoalPtrs::operator()(const GoalPtr& a, const GoalPtr& b) const {
-  string s1 = a->key();
-  string s2 = b->key();
+  std::string s1 = a->key();
+  std::string s2 = b->key();
   return s1 < s2;
 }
 
@@ -185,7 +183,7 @@ using steady_time_point = std::chrono::time_point<std::chrono::steady_clock>;
 struct Child {
   WeakGoalPtr goal;
   Goal* goal2;  // ugly hackery
-  set<int> fds;
+  std::set<int> fds;
   bool respectTimeouts;
   bool inBuildSlot;
   steady_time_point lastOutput; /* time we last got output on stdout/stderr */
@@ -293,8 +291,8 @@ class Worker {
 
   /* Registers a running child process.  `inBuildSlot' means that
      the process counts towards the jobs limit. */
-  void childStarted(const GoalPtr& goal, const set<int>& fds, bool inBuildSlot,
-                    bool respectTimeouts);
+  void childStarted(const GoalPtr& goal, const std::set<int>& fds,
+                    bool inBuildSlot, bool respectTimeouts);
 
   /* Unregisters a running child process.  `wakeSleepers' should be
      false if there is no sense in waking up goals that are sleeping
@@ -483,7 +481,7 @@ class UserLock {
   Path fnUserLock;
   AutoCloseFD fdUserLock;
 
-  string user;
+  std::string user;
   uid_t uid;
   gid_t gid;
   std::vector<gid_t> supplementaryGIDs;
@@ -494,7 +492,7 @@ class UserLock {
 
   void kill();
 
-  string getUser() { return user; }
+  std::string getUser() { return user; }
   uid_t getUID() {
     assert(uid);
     return uid;
@@ -710,12 +708,12 @@ HookInstance::~HookInstance() {
 
 //////////////////////////////////////////////////////////////////////
 
-typedef map<std::string, std::string> StringRewrites;
+typedef std::map<std::string, std::string> StringRewrites;
 
 std::string rewriteStrings(std::string s, const StringRewrites& rewrites) {
   for (auto& i : rewrites) {
     size_t j = 0;
-    while ((j = s.find(i.first, j)) != string::npos) {
+    while ((j = s.find(i.first, j)) != std::string::npos) {
       s.replace(j, i.first.size(), i.second);
     }
   }
@@ -831,16 +829,16 @@ class DerivationGoal : public Goal {
     explicit ChrootPath(Path source = "", bool optional = false)
         : source(std::move(source)), optional(optional) {}
   };
-  typedef map<Path, ChrootPath>
+  typedef std::map<Path, ChrootPath>
       DirsInChroot;  // maps target path to source path
   DirsInChroot dirsInChroot;
 
-  typedef map<string, string> Environment;
+  typedef std::map<std::string, std::string> Environment;
   Environment env;
 
   /* Hash rewriting. */
   StringRewrites inputRewrites, outputRewrites;
-  typedef map<Path, Path> RedirectedOutputs;
+  typedef std::map<Path, Path> RedirectedOutputs;
   RedirectedOutputs redirectedOutputs;
 
   BuildMode buildMode;
@@ -886,7 +884,7 @@ class DerivationGoal : public Goal {
 
   void timedOut() override;
 
-  string key() override {
+  std::string key() override {
     /* Ensure that derivations get built in order of their name,
        i.e. a derivation named "aardvark" always comes before
        "baboon". And substitution goals always happen before
@@ -956,7 +954,7 @@ class DerivationGoal : public Goal {
   void deleteTmpDir(bool force);
 
   /* Callback used by the worker to write to the log. */
-  void handleChildOutput(int fd, const string& data) override;
+  void handleChildOutput(int fd, const std::string& data) override;
   void handleEOF(int fd) override;
   void flushLine();
 
@@ -975,7 +973,7 @@ class DerivationGoal : public Goal {
 
   void amDone(ExitCode result) override { Goal::amDone(result); }
 
-  void done(BuildResult::Status status, const string& msg = "");
+  void done(BuildResult::Status status, const std::string& msg = "");
 
   PathSet exportReferences(const PathSet& storePaths);
 };
@@ -1036,9 +1034,7 @@ DerivationGoal::~DerivationGoal() {
   }
 }
 
-inline bool DerivationGoal::needsHashRewrite() {
-  return !useChroot;
-}
+inline bool DerivationGoal::needsHashRewrite() { return !useChroot; }
 
 void DerivationGoal::killChild() {
   if (pid != -1) {
@@ -1762,11 +1758,11 @@ HookReply DerivationGoal::tryBuildHook() {
 
     /* Read the first line of input, which should be a word indicating
        whether the hook wishes to perform the build. */
-    string reply;
+    std::string reply;
     while (true) {
-      string s = readLine(worker.hook->fromHook.readSide.get());
-      if (string(s, 0, 2) == "# ") {
-        reply = string(s, 2);
+      std::string s = readLine(worker.hook->fromHook.readSide.get());
+      if (std::string(s, 0, 2) == "# ") {
+        reply = std::string(s, 2);
         break;
       }
       s += "\n";
@@ -1816,7 +1812,7 @@ HookReply DerivationGoal::tryBuildHook() {
   /* Create the log file and pipe. */
   Path logFile = openLogFile();
 
-  set<int> fds;
+  std::set<int> fds;
   fds.insert(hook->fromHook.readSide.get());
   fds.insert(hook->builderOut.readSide.get());
   worker.childStarted(shared_from_this(), fds, false, false);
@@ -1970,14 +1966,14 @@ void DerivationGoal::startBuilder() {
        temporary build directory.  The text files have the format used
        by `nix-store --register-validity'.  However, the deriver
        fields are left empty. */
-    string s = get(drv->env, "exportReferencesGraph");
+    std::string s = get(drv->env, "exportReferencesGraph");
     auto ss = tokenizeString<Strings>(s);
     if (ss.size() % 2 != 0) {
       throw BuildError(
           format("odd number of tokens in 'exportReferencesGraph': '%1%'") % s);
     }
     for (auto i = ss.begin(); i != ss.end();) {
-      string fileName = *i++;
+      std::string fileName = *i++;
       checkStoreName(fileName); /* !!! abuse of this function */
       Path storePath = *i++;
 
@@ -2007,10 +2003,11 @@ void DerivationGoal::startBuilder() {
         i.pop_back();
       }
       size_t p = i.find('=');
-      if (p == string::npos) {
+      if (p == std::string::npos) {
         dirsInChroot[i] = ChrootPath(i, optional);
       } else {
-        dirsInChroot[string(i, 0, p)] = ChrootPath(string(i, p + 1), optional);
+        dirsInChroot[std::string(i, 0, p)] =
+            ChrootPath(std::string(i, p + 1), optional);
       }
     }
     dirsInChroot[tmpDirInSandbox] = ChrootPath(tmpDir);
@@ -2211,7 +2208,7 @@ void DerivationGoal::startBuilder() {
     auto state = stBegin;
     auto lines = runProgram(settings.preBuildHook, false, args);
     auto lastPos = std::string::size_type{0};
-    for (auto nlPos = lines.find('\n'); nlPos != string::npos;
+    for (auto nlPos = lines.find('\n'); nlPos != std::string::npos;
          nlPos = lines.find('\n', lastPos)) {
       auto line = std::string{lines, lastPos, nlPos - lastPos};
       lastPos = nlPos + 1;
@@ -2226,10 +2223,11 @@ void DerivationGoal::startBuilder() {
           state = stBegin;
         } else {
           auto p = line.find('=');
-          if (p == string::npos) {
+          if (p == std::string::npos) {
             dirsInChroot[line] = ChrootPath(line);
           } else {
-            dirsInChroot[string(line, 0, p)] = ChrootPath(string(line, p + 1));
+            dirsInChroot[std::string(line, 0, p)] =
+                ChrootPath(std::string(line, p + 1));
           }
         }
       }
@@ -2454,12 +2452,12 @@ void DerivationGoal::startBuilder() {
 
   /* Check if setting up the build environment failed. */
   while (true) {
-    string msg = readLine(builderOut.readSide.get());
-    if (string(msg, 0, 1) == "\1") {
+    std::string msg = readLine(builderOut.readSide.get());
+    if (std::string(msg, 0, 1) == "\1") {
       if (msg.size() == 1) {
         break;
       }
-      throw Error(string(msg, 1));
+      throw Error(std::string(msg, 1));
     }
     DLOG(INFO) << msg;
   }
@@ -2488,7 +2486,7 @@ void DerivationGoal::initTmpDir() {
       if (passAsFile.find(i.first) == passAsFile.end()) {
         env[i.first] = i.second;
       } else {
-        string fn = ".attr-" + std::to_string(fileNr++);
+        std::string fn = ".attr-" + std::to_string(fileNr++);
         Path p = tmpDir + "/" + fn;
         writeFile(p, rewriteStrings(i.second, inputRewrites));
         chownToBuilder(p);
@@ -3110,7 +3108,7 @@ void DerivationGoal::runChild() {
 
     if (!drv->isBuiltin()) {
       builder = drv->builder.c_str();
-      string builderBasename = baseNameOf(drv->builder);
+      std::string builderBasename = baseNameOf(drv->builder);
       args.push_back(builderBasename);
     }
 
@@ -3119,7 +3117,7 @@ void DerivationGoal::runChild() {
     }
 
     /* Indicate that we managed to set up the build environment. */
-    writeFull(STDERR_FILENO, string("\1\n"));
+    writeFull(STDERR_FILENO, std::string("\1\n"));
 
     /* Execute the program.  This should not return. */
     if (drv->isBuiltin()) {
@@ -3135,11 +3133,11 @@ void DerivationGoal::runChild() {
           builtinBuildenv(drv2);
         } else {
           throw Error(format("unsupported builtin function '%1%'") %
-                      string(drv->builder, 8));
+                      std::string(drv->builder, 8));
         }
         _exit(0);
       } catch (std::exception& e) {
-        writeFull(STDERR_FILENO, "error: " + string(e.what()) + "\n");
+        writeFull(STDERR_FILENO, "error: " + std::string(e.what()) + "\n");
         _exit(1);
       }
     }
@@ -3151,7 +3149,7 @@ void DerivationGoal::runChild() {
 
   } catch (std::exception& e) {
     writeFull(STDERR_FILENO, "\1while setting up the build environment: " +
-                                 string(e.what()) + "\n");
+                                 std::string(e.what()) + "\n");
     _exit(1);
   }
 }
@@ -3621,7 +3619,7 @@ void DerivationGoal::checkOutputs(
         }
 
         if (!badPaths.empty()) {
-          string badPathsStr;
+          std::string badPathsStr;
           for (auto& i : badPaths) {
             badPathsStr += "\n  ";
             badPathsStr += i;
@@ -3705,14 +3703,14 @@ Path DerivationGoal::openLogFile() {
     return "";
   }
 
-  string baseName = baseNameOf(drvPath);
+  std::string baseName = baseNameOf(drvPath);
 
   /* Create a log file. */
   Path dir = fmt("%s/%s/%s/", worker.store.logDir, nix::LocalStore::drvsLogDir,
-                 string(baseName, 0, 2));
+                 std::string(baseName, 0, 2));
   createDirs(dir);
 
-  Path logFileName = fmt("%s/%s%s", dir, string(baseName, 2),
+  Path logFileName = fmt("%s/%s%s", dir, std::string(baseName, 2),
                          settings.compressLog ? ".bz2" : "");
 
   fdLogFile =
@@ -3759,7 +3757,7 @@ void DerivationGoal::deleteTmpDir(bool force) {
   }
 }
 
-void DerivationGoal::handleChildOutput(int fd, const string& data) {
+void DerivationGoal::handleChildOutput(int fd, const std::string& data) {
   if ((hook && fd == hook->builderOut.readSide.get()) ||
       (!hook && fd == builderOut.readSide.get())) {
     logSize += data.size();
@@ -3839,12 +3837,13 @@ PathSet DerivationGoal::checkPathValidity(bool returnValid, bool checkHash) {
 }
 
 Path DerivationGoal::addHashRewrite(const Path& path) {
-  string h1 = string(path, worker.store.storeDir.size() + 1, 32);
-  string h2 = string(hashString(htSHA256, "rewrite:" + drvPath + ":" + path)
-                         .to_string(Base32, false),
-                     0, 32);
+  std::string h1 = std::string(path, worker.store.storeDir.size() + 1, 32);
+  std::string h2 =
+      std::string(hashString(htSHA256, "rewrite:" + drvPath + ":" + path)
+                      .to_string(Base32, false),
+                  0, 32);
   Path p = worker.store.storeDir + "/" + h2 +
-           string(path, worker.store.storeDir.size() + 33);
+           std::string(path, worker.store.storeDir.size() + 33);
   deletePath(p);
   assert(path.size() == p.size());
   inputRewrites[h1] = h2;
@@ -3853,7 +3852,7 @@ Path DerivationGoal::addHashRewrite(const Path& path) {
   return p;
 }
 
-void DerivationGoal::done(BuildResult::Status status, const string& msg) {
+void DerivationGoal::done(BuildResult::Status status, const std::string& msg) {
   result.status = status;
   result.errorMsg = msg;
   amDone(result.success() ? ecSuccess : ecFailed);
@@ -3928,7 +3927,7 @@ class SubstitutionGoal : public Goal {
 
   void timedOut() override { abort(); };
 
-  string key() override {
+  std::string key() override {
     /* "a$" ensures substitution goals happen before derivation
        goals. */
     return "a$" + storePathToName(storePath) + "$" + storePath;
@@ -3945,7 +3944,7 @@ class SubstitutionGoal : public Goal {
   void finished();
 
   /* Callback used by the worker to write to the log. */
-  void handleChildOutput(int fd, const string& data) override;
+  void handleChildOutput(int fd, const std::string& data) override;
   void handleEOF(int fd) override;
 
   Path getStorePath() { return storePath; }
@@ -4204,7 +4203,7 @@ void SubstitutionGoal::finished() {
   amDone(ecSuccess);
 }
 
-void SubstitutionGoal::handleChildOutput(int fd, const string& data) {}
+void SubstitutionGoal::handleChildOutput(int fd, const std::string& data) {}
 
 void SubstitutionGoal::handleEOF(int fd) {
   if (fd == outPipe.readSide.get()) {
@@ -4321,7 +4320,7 @@ void Worker::wakeUp(const GoalPtr& goal) {
 
 unsigned Worker::getNrLocalBuilds() { return nrLocalBuilds; }
 
-void Worker::childStarted(const GoalPtr& goal, const set<int>& fds,
+void Worker::childStarted(const GoalPtr& goal, const std::set<int>& fds,
                           bool inBuildSlot, bool respectTimeouts) {
   Child child;
   child.goal = goal;
@@ -4545,7 +4544,7 @@ void Worker::waitForInput() {
     GoalPtr goal = j->goal.lock();
     assert(goal);
 
-    set<int> fds2(j->fds);
+    std::set<int> fds2(j->fds);
     std::vector<unsigned char> buffer(4096);
     for (auto& k : fds2) {
       if (FD_ISSET(k, &fds)) {
@@ -4562,7 +4561,7 @@ void Worker::waitForInput() {
           }
         } else {
           DLOG(INFO) << goal->getName() << ": read " << rd << " bytes";
-          string data((char*)buffer.data(), rd);
+          std::string data((char*)buffer.data(), rd);
           j->lastOutput = after;
           goal->handleChildOutput(k, data);
         }
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc
index 77ad722fab15..d14474a93d7e 100644
--- a/third_party/nix/src/libstore/builtins/buildenv.cc
+++ b/third_party/nix/src/libstore/builtins/buildenv.cc
@@ -133,7 +133,7 @@ static void addPkg(const Path& pkgDir, int priority) {
   createLinks(pkgDir, out, priority);
 
   try {
-    for (const auto& p : tokenizeString<std::vector<string>>(
+    for (const auto& p : tokenizeString<std::vector<std::string>>(
              readFile(pkgDir + "/nix-support/propagated-user-env-packages"),
              " \n"))
       if (!done.count(p)) {
@@ -157,7 +157,7 @@ struct Package {
 typedef std::vector<Package> Packages;
 
 void builtinBuildenv(const BasicDerivation& drv) {
-  auto getAttr = [&](const string& name) {
+  auto getAttr = [&](const std::string& name) {
     auto i = drv.env.find(name);
     if (i == drv.env.end()) {
       throw Error("attribute '%s' missing", name);
diff --git a/third_party/nix/src/libstore/builtins/fetchurl.cc b/third_party/nix/src/libstore/builtins/fetchurl.cc
index c3f38a943f57..97260d2e5229 100644
--- a/third_party/nix/src/libstore/builtins/fetchurl.cc
+++ b/third_party/nix/src/libstore/builtins/fetchurl.cc
@@ -17,7 +17,7 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) {
     writeFile(settings.netrcFile, netrcData, 0600);
   }
 
-  auto getAttr = [&](const string& name) {
+  auto getAttr = [&](const std::string& name) {
     auto i = drv.env.find(name);
     if (i == drv.env.end())
       throw Error(format("attribute '%s' missing") % name);
diff --git a/third_party/nix/src/libstore/crypto.cc b/third_party/nix/src/libstore/crypto.cc
index 90580b8dc902..eb5bb6670738 100644
--- a/third_party/nix/src/libstore/crypto.cc
+++ b/third_party/nix/src/libstore/crypto.cc
@@ -9,7 +9,7 @@
 
 namespace nix {
 
-static std::pair<std::string, std::string> split(const string& s) {
+static std::pair<std::string, std::string> split(const std::string& s) {
   size_t colon = s.find(':');
   if (colon == std::string::npos || colon == 0) {
     return {"", ""};
@@ -17,7 +17,7 @@ static std::pair<std::string, std::string> split(const string& s) {
   return {std::string(s, 0, colon), std::string(s, colon + 1)};
 }
 
-Key::Key(const string& s) {
+Key::Key(const std::string& s) {
   auto ss = split(s);
 
   name = ss.first;
@@ -30,7 +30,7 @@ Key::Key(const string& s) {
   key = base64Decode(key);
 }
 
-SecretKey::SecretKey(const string& s) : Key(s) {
+SecretKey::SecretKey(const std::string& s) : Key(s) {
 #if HAVE_SODIUM
   if (key.size() != crypto_sign_SECRETKEYBYTES) {
     throw Error("secret key is not valid");
@@ -68,7 +68,7 @@ PublicKey SecretKey::toPublicKey() const {
 #endif
 }
 
-PublicKey::PublicKey(const string& s) : Key(s) {
+PublicKey::PublicKey(const std::string& s) : Key(s) {
 #if HAVE_SODIUM
   if (key.size() != crypto_sign_PUBLICKEYBYTES) {
     throw Error("public key is not valid");
diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc
index 9c71d7209e37..f8770327bf9e 100644
--- a/third_party/nix/src/libstore/derivations.cc
+++ b/third_party/nix/src/libstore/derivations.cc
@@ -11,11 +11,11 @@ namespace nix {
 
 void DerivationOutput::parseHashInfo(bool& recursive, Hash& hash) const {
   recursive = false;
-  string algo = hashAlgo;
+  std::string algo = hashAlgo;
 
-  if (string(algo, 0, 2) == "r:") {
+  if (std::string(algo, 0, 2) == "r:") {
     recursive = true;
-    algo = string(algo, 2);
+    algo = std::string(algo, 2);
   }
 
   HashType hashType = parseHashType(algo);
@@ -26,7 +26,7 @@ void DerivationOutput::parseHashInfo(bool& recursive, Hash& hash) const {
   hash = Hash(this->hash, hashType);
 }
 
-Path BasicDerivation::findOutput(const string& id) const {
+Path BasicDerivation::findOutput(const std::string& id) const {
   auto i = outputs.find(id);
   if (i == outputs.end()) {
     throw Error(format("derivation has no output '%1%'") % id);
@@ -35,11 +35,11 @@ Path BasicDerivation::findOutput(const string& id) const {
 }
 
 bool BasicDerivation::isBuiltin() const {
-  return string(builder, 0, 8) == "builtin:";
+  return std::string(builder, 0, 8) == "builtin:";
 }
 
 Path writeDerivation(const ref<Store>& store, const Derivation& drv,
-                     const string& name, RepairFlag repair) {
+                     const std::string& name, RepairFlag repair) {
   PathSet references;
   references.insert(drv.inputSrcs.begin(), drv.inputSrcs.end());
   for (auto& i : drv.inputDrvs) {
@@ -48,25 +48,25 @@ Path writeDerivation(const ref<Store>& store, const Derivation& drv,
   /* Note that the outputs of a derivation are *not* references
      (that can be missing (of course) and should not necessarily be
      held during a garbage collection). */
-  string suffix = name + drvExtension;
-  string contents = drv.unparse();
+  std::string suffix = name + drvExtension;
+  std::string contents = drv.unparse();
   return settings.readOnlyMode
              ? store->computeStorePathForText(suffix, contents, references)
              : store->addTextToStore(suffix, contents, references, repair);
 }
 
 /* Read string `s' from stream `str'. */
-static void expect(std::istream& str, const string& s) {
+static void expect(std::istream& str, const std::string& s) {
   char s2[s.size()];
   str.read(s2, s.size());
-  if (string(s2, s.size()) != s) {
+  if (std::string(s2, s.size()) != s) {
     throw FormatError(format("expected string '%1%'") % s);
   }
 }
 
 /* Read a C-style string from stream `str'. */
-static string parseString(std::istream& str) {
-  string res;
+static std::string parseString(std::istream& str) {
+  std::string res;
   expect(str, "\"");
   int c;
   while ((c = str.get()) != '"') {
@@ -89,7 +89,7 @@ static string parseString(std::istream& str) {
 }
 
 static Path parsePath(std::istream& str) {
-  string s = parseString(str);
+  std::string s = parseString(str);
   if (s.empty() || s[0] != '/') {
     throw FormatError(format("bad path '%1%' in derivation") % s);
   }
@@ -116,7 +116,7 @@ static StringSet parseStrings(std::istream& str, bool arePaths) {
   return res;
 }
 
-static Derivation parseDerivation(const string& s) {
+static Derivation parseDerivation(const std::string& s) {
   Derivation drv;
   istringstream_nocopy str(s);
   expect(str, "Derive([");
@@ -125,7 +125,7 @@ static Derivation parseDerivation(const string& s) {
   while (!endOfList(str)) {
     DerivationOutput out;
     expect(str, "(");
-    string id = parseString(str);
+    std::string id = parseString(str);
     expect(str, ",");
     out.path = parsePath(str);
     expect(str, ",");
@@ -163,9 +163,9 @@ static Derivation parseDerivation(const string& s) {
   expect(str, ",[");
   while (!endOfList(str)) {
     expect(str, "(");
-    string name = parseString(str);
+    std::string name = parseString(str);
     expect(str, ",");
-    string value = parseString(str);
+    std::string value = parseString(str);
     expect(str, ")");
     drv.env[name] = value;
   }
@@ -195,7 +195,7 @@ Derivation Store::derivationFromPath(const Path& drvPath) {
   }
 }
 
-static void printString(string& res, const string& s) {
+static void printString(std::string& res, const std::string& s) {
   res += '"';
   for (const char* i = s.c_str(); *i != 0; i++) {
     if (*i == '\"' || *i == '\\') {
@@ -215,7 +215,8 @@ static void printString(string& res, const string& s) {
 }
 
 template <class ForwardIterator>
-static void printStrings(string& res, ForwardIterator i, ForwardIterator j) {
+static void printStrings(std::string& res, ForwardIterator i,
+                         ForwardIterator j) {
   res += '[';
   bool first = true;
   for (; i != j; ++i) {
@@ -229,8 +230,8 @@ static void printStrings(string& res, ForwardIterator i, ForwardIterator j) {
   res += ']';
 }
 
-string Derivation::unparse() const {
-  string s;
+std::string Derivation::unparse() const {
+  std::string s;
   s.reserve(65536);
   s += "Derive([";
 
@@ -297,7 +298,7 @@ string Derivation::unparse() const {
   return s;
 }
 
-bool isDerivation(const string& fileName) {
+bool isDerivation(const std::string& fileName) {
   return hasSuffix(fileName, drvExtension);
 }
 
@@ -354,22 +355,23 @@ Hash hashDerivationModulo(Store& store, Derivation drv) {
   return hashString(htSHA256, drv.unparse());
 }
 
-DrvPathWithOutputs parseDrvPathWithOutputs(const string& s) {
+DrvPathWithOutputs parseDrvPathWithOutputs(const std::string& s) {
   size_t n = s.find('!');
   return n == std::string::npos
-             ? DrvPathWithOutputs(s, std::set<string>())
-             : DrvPathWithOutputs(
-                   string(s, 0, n),
-                   tokenizeString<std::set<string> >(string(s, n + 1), ","));
+             ? DrvPathWithOutputs(s, std::set<std::string>())
+             : DrvPathWithOutputs(std::string(s, 0, n),
+                                  tokenizeString<std::set<std::string> >(
+                                      std::string(s, n + 1), ","));
 }
 
 Path makeDrvPathWithOutputs(const Path& drvPath,
-                            const std::set<string>& outputs) {
+                            const std::set<std::string>& outputs) {
   return outputs.empty() ? drvPath
                          : drvPath + "!" + concatStringsSep(",", outputs);
 }
 
-bool wantOutput(const string& output, const std::set<string>& wanted) {
+bool wantOutput(const std::string& output,
+                const std::set<std::string>& wanted) {
   return wanted.empty() || wanted.find(output) != wanted.end();
 }
 
diff --git a/third_party/nix/src/libstore/derivations.hh b/third_party/nix/src/libstore/derivations.hh
index 52b951f5e9d9..ae365e68bf3a 100644
--- a/third_party/nix/src/libstore/derivations.hh
+++ b/third_party/nix/src/libstore/derivations.hh
@@ -9,16 +9,16 @@
 namespace nix {
 
 /* Extension of derivations in the Nix store. */
-const string drvExtension = ".drv";
+const std::string drvExtension = ".drv";
 
 /* Abstract syntax of derivations. */
 
 struct DerivationOutput {
   Path path;
-  string hashAlgo; /* hash used for expected hash computation */
-  string hash;     /* expected hash, may be null */
+  std::string hashAlgo; /* hash used for expected hash computation */
+  std::string hash;     /* expected hash, may be null */
   DerivationOutput() {}
-  DerivationOutput(Path path, string hashAlgo, string hash) {
+  DerivationOutput(Path path, std::string hashAlgo, std::string hash) {
     this->path = path;
     this->hashAlgo = hashAlgo;
     this->hash = hash;
@@ -26,18 +26,18 @@ struct DerivationOutput {
   void parseHashInfo(bool& recursive, Hash& hash) const;
 };
 
-typedef std::map<string, DerivationOutput> DerivationOutputs;
+typedef std::map<std::string, DerivationOutput> DerivationOutputs;
 
 /* For inputs that are sub-derivations, we specify exactly which
    output IDs we are interested in. */
 typedef std::map<Path, StringSet> DerivationInputs;
 
-typedef std::map<string, string> StringPairs;
+typedef std::map<std::string, std::string> StringPairs;
 
 struct BasicDerivation {
   DerivationOutputs outputs; /* keyed on symbolic IDs */
   PathSet inputSrcs;         /* inputs that are sources */
-  string platform;
+  std::string platform;
   Path builder;
   Strings args;
   StringPairs env;
@@ -46,7 +46,7 @@ struct BasicDerivation {
 
   /* Return the path corresponding to the output identifier `id' in
      the given derivation. */
-  Path findOutput(const string& id) const;
+  Path findOutput(const std::string& id) const;
 
   bool isBuiltin() const;
 
@@ -68,14 +68,14 @@ class Store;
 
 /* Write a derivation to the Nix store, and return its path. */
 Path writeDerivation(const ref<Store>& store, const Derivation& drv,
-                     const string& name, RepairFlag repair = NoRepair);
+                     const std::string& name, RepairFlag repair = NoRepair);
 
 /* Read a derivation from a file. */
 Derivation readDerivation(const Path& drvPath);
 
 /* Check whether a file name ends with the extension for
    derivations. */
-bool isDerivation(const string& fileName);
+bool isDerivation(const std::string& fileName);
 
 Hash hashDerivationModulo(Store& store, Derivation drv);
 
@@ -87,13 +87,13 @@ extern DrvHashes drvHashes;  // FIXME: global, not thread-safe
 /* Split a string specifying a derivation and a set of outputs
    (/nix/store/hash-foo!out1,out2,...) into the derivation path and
    the outputs. */
-typedef std::pair<string, std::set<string> > DrvPathWithOutputs;
-DrvPathWithOutputs parseDrvPathWithOutputs(const string& s);
+typedef std::pair<std::string, std::set<std::string> > DrvPathWithOutputs;
+DrvPathWithOutputs parseDrvPathWithOutputs(const std::string& s);
 
 Path makeDrvPathWithOutputs(const Path& drvPath,
-                            const std::set<string>& outputs);
+                            const std::set<std::string>& outputs);
 
-bool wantOutput(const string& output, const std::set<string>& wanted);
+bool wantOutput(const std::string& output, const std::set<std::string>& wanted);
 
 struct Source;
 struct Sink;
diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc
index 876734478785..c96caf474c0d 100644
--- a/third_party/nix/src/libstore/download.cc
+++ b/third_party/nix/src/libstore/download.cc
@@ -177,7 +177,7 @@ struct CurlDownloader : public Downloader {
       DLOG(INFO) << "got header for '" << request.uri << "': " << trim(line);
       if (line.compare(0, 5, "HTTP/") == 0) {  // new response starts
         result.etag = "";
-        auto ss = tokenizeString<vector<string>>(line, " ");
+        auto ss = tokenizeString<std::vector<std::string>>(line, " ");
         status = ss.size() >= 2 ? ss[1] : "";
         result.data = std::make_shared<std::string>();
         result.bodySize = 0;
@@ -185,10 +185,10 @@ struct CurlDownloader : public Downloader {
         encoding = "";
       } else {
         auto i = line.find(':');
-        if (i != string::npos) {
-          string name = toLower(trim(string(line, 0, i)));
+        if (i != std::string::npos) {
+          std::string name = toLower(trim(std::string(line, 0, i)));
           if (name == "etag") {
-            result.etag = trim(string(line, i + 1));
+            result.etag = trim(std::string(line, i + 1));
             /* Hack to work around a GitHub bug: it sends
                ETags, but ignores If-None-Match. So if we get
                the expected ETag on a 200 response, then shut
@@ -200,7 +200,7 @@ struct CurlDownloader : public Downloader {
               return 0;
             }
           } else if (name == "content-encoding") {
-            encoding = trim(string(line, i + 1));
+            encoding = trim(std::string(line, i + 1));
           } else if (name == "accept-ranges" &&
                      toLower(trim(std::string(line, i + 1))) == "bytes") {
             acceptRanges = true;
@@ -868,8 +868,8 @@ CachedDownloadResult Downloader::downloadCached(
   auto name = request.name;
   if (name.empty()) {
     auto p = url.rfind('/');
-    if (p != string::npos) {
-      name = string(url, p + 1);
+    if (p != std::string::npos) {
+      name = std::string(url, p + 1);
     }
   }
 
@@ -888,8 +888,8 @@ CachedDownloadResult Downloader::downloadCached(
   Path cacheDir = getCacheDir() + "/nix/tarballs";
   createDirs(cacheDir);
 
-  string urlHash = hashString(htSHA256, name + std::string("\0"s) + url)
-                       .to_string(Base32, false);
+  std::string urlHash = hashString(htSHA256, name + std::string("\0"s) + url)
+                            .to_string(Base32, false);
 
   Path dataFile = cacheDir + "/" + urlHash + ".info";
   Path fileLink = cacheDir + "/" + urlHash + "-file";
@@ -898,7 +898,7 @@ CachedDownloadResult Downloader::downloadCached(
 
   Path storePath;
 
-  string expectedETag;
+  std::string expectedETag;
 
   bool skip = false;
 
@@ -908,7 +908,8 @@ CachedDownloadResult Downloader::downloadCached(
     storePath = readLink(fileLink);
     store->addTempRoot(storePath);
     if (store->isValidPath(storePath)) {
-      auto ss = tokenizeString<vector<string>>(readFile(dataFile), "\n");
+      auto ss =
+          tokenizeString<std::vector<std::string>>(readFile(dataFile), "\n");
       if (ss.size() >= 3 && ss[0] == url) {
         time_t lastChecked;
         if (string2Int(ss[2], lastChecked) &&
@@ -1009,15 +1010,15 @@ CachedDownloadResult Downloader::downloadCached(
   return result;
 }
 
-bool isUri(const string& s) {
+bool isUri(const std::string& s) {
   if (s.compare(0, 8, "channel:") == 0) {
     return true;
   }
   size_t pos = s.find("://");
-  if (pos == string::npos) {
+  if (pos == std::string::npos) {
     return false;
   }
-  string scheme(s, 0, pos);
+  std::string scheme(s, 0, pos);
   return scheme == "http" || scheme == "https" || scheme == "file" ||
          scheme == "channel" || scheme == "git" || scheme == "s3" ||
          scheme == "ssh";
diff --git a/third_party/nix/src/libstore/download.hh b/third_party/nix/src/libstore/download.hh
index 9ddbdfc15955..a988ec682669 100644
--- a/third_party/nix/src/libstore/download.hh
+++ b/third_party/nix/src/libstore/download.hh
@@ -128,6 +128,6 @@ class DownloadError : public Error {
       : Error(fs), error(error) {}
 };
 
-bool isUri(const string& s);
+bool isUri(const std::string& s);
 
 }  // namespace nix
diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc
index bc3393265e48..1b2364c25383 100644
--- a/third_party/nix/src/libstore/gc.cc
+++ b/third_party/nix/src/libstore/gc.cc
@@ -20,8 +20,8 @@
 
 namespace nix {
 
-static string gcLockName = "gc.lock";
-static string gcRootsDir = "gcroots";
+static std::string gcLockName = "gc.lock";
+static std::string gcRootsDir = "gcroots";
 
 /* Acquire the global GC lock.  This is used to prevent new Nix
    processes from starting after the temporary root files have been
@@ -69,7 +69,7 @@ static void makeSymlink(const Path& link, const Path& target) {
 void LocalStore::syncWithGC() { AutoCloseFD fdGCLock = openGCLock(ltRead); }
 
 void LocalStore::addIndirectRoot(const Path& path) {
-  string hash = hashString(htSHA1, path).to_string(Base32, false);
+  std::string hash = hashString(htSHA1, path).to_string(Base32, false);
   Path realRoot = canonPath(
       (format("%1%/%2%/auto/%3%") % stateDir % gcRootsDir % hash).str());
   makeSymlink(realRoot, path);
@@ -105,7 +105,7 @@ Path LocalFSStore::addPermRoot(const Path& _storePath, const Path& _gcRoot,
       Path rootsDir =
           canonPath((format("%1%/%2%") % stateDir % gcRootsDir).str());
 
-      if (string(gcRoot, 0, rootsDir.size() + 1) != rootsDir + "/") {
+      if (std::string(gcRoot, 0, rootsDir.size() + 1) != rootsDir + "/") {
         throw Error(format("path '%1%' is not a valid garbage collector root; "
                            "it's not in the directory '%2%'") %
                     gcRoot % rootsDir);
@@ -184,7 +184,7 @@ void LocalStore::addTempRoot(const Path& path) {
   DLOG(INFO) << "acquiring write lock on " << fnTempRoots;
   lockFile(state->fdTempRoots.get(), ltWrite, true);
 
-  string s = path + '\0';
+  std::string s = path + '\0';
   writeFull(state->fdTempRoots.get(), s);
 
   /* Downgrade to a read lock. */
@@ -233,13 +233,13 @@ void LocalStore::findTempRoots(FDs& fds, Roots& tempRoots, bool censor) {
     lockFile(fd->get(), ltRead, true);
 
     /* Read the entire file. */
-    string contents = readFile(fd->get());
+    std::string contents = readFile(fd->get());
 
     /* Extract the roots. */
-    string::size_type pos = 0;
-    string::size_type end;
+    std::string::size_type pos = 0;
+    std::string::size_type end;
 
-    while ((end = contents.find((char)0, pos)) != string::npos) {
+    while ((end = contents.find((char)0, pos)) != std::string::npos) {
       Path root(contents, pos, end - pos);
       DLOG(INFO) << "got temporary root " << root;
       assertStorePath(root);
@@ -341,7 +341,7 @@ Roots LocalStore::findRoots(bool censor) {
   return roots;
 }
 
-static void readProcLink(const string& file, Roots& roots) {
+static void readProcLink(const std::string& file, Roots& roots) {
   /* 64 is the starting buffer size gnu readlink uses... */
   auto bufsiz = ssize_t{64};
 try_again:
@@ -365,7 +365,7 @@ try_again:
   }
 }
 
-static string quoteRegexChars(const string& raw) {
+static std::string quoteRegexChars(const std::string& raw) {
   static auto specialRegex = std::regex(R"([.^$\\*+?()\[\]{}|])");
   return std::regex_replace(raw, specialRegex, R"(\$&)");
 }
@@ -421,7 +421,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
 
         try {
           auto mapFile = fmt("/proc/%s/maps", ent->d_name);
-          auto mapLines = tokenizeString<std::vector<string>>(
+          auto mapLines = tokenizeString<std::vector<std::string>>(
               readFile(mapFile, true), "\n");
           for (const auto& line : mapLines) {
             auto match = std::smatch{};
@@ -458,7 +458,7 @@ void LocalStore::findRuntimeRoots(Roots& roots, bool censor) {
   if (getEnv("_NIX_TEST_NO_LSOF") == "") {
     try {
       std::regex lsofRegex(R"(^n(/.*)$)");
-      auto lsofLines = tokenizeString<std::vector<string>>(
+      auto lsofLines = tokenizeString<std::vector<std::string>>(
           runProgram(LSOF, true, {"-n", "-w", "-F", "n"}), "\n");
       for (const auto& line : lsofLines) {
         std::smatch match;
@@ -511,10 +511,10 @@ struct LocalStore::GCState {
 };
 
 bool LocalStore::isActiveTempFile(const GCState& state, const Path& path,
-                                  const string& suffix) {
+                                  const std::string& suffix) {
   return hasSuffix(path, suffix) &&
-         state.tempRoots.find(string(path, 0, path.size() - suffix.size())) !=
-             state.tempRoots.end();
+         state.tempRoots.find(std::string(
+             path, 0, path.size() - suffix.size())) != state.tempRoots.end();
 }
 
 void LocalStore::deleteGarbage(GCState& state, const Path& path) {
@@ -720,7 +720,7 @@ void LocalStore::removeUnusedLinks(const GCState& state) {
   struct dirent* dirent;
   while (errno = 0, dirent = readdir(dir.get())) {
     checkInterrupt();
-    string name = dirent->d_name;
+    std::string name = dirent->d_name;
     if (name == "." || name == "..") {
       continue;
     }
@@ -863,7 +863,7 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
       struct dirent* dirent;
       while (errno = 0, dirent = readdir(dir.get())) {
         checkInterrupt();
-        string name = dirent->d_name;
+        std::string name = dirent->d_name;
         if (name == "." || name == "..") {
           continue;
         }
@@ -882,7 +882,7 @@ void LocalStore::collectGarbage(const GCOptions& options, GCResults& results) {
          less biased towards deleting paths that come
          alphabetically first (e.g. /nix/store/000...).  This
          matters when using --max-freed etc. */
-      vector<Path> entries_(entries.begin(), entries.end());
+      std::vector<Path> entries_(entries.begin(), entries.end());
       std::mt19937 gen(1);
       std::shuffle(entries_.begin(), entries_.end(), gen);
 
diff --git a/third_party/nix/src/libstore/globals.cc b/third_party/nix/src/libstore/globals.cc
index 856b858368ef..61293dffed50 100644
--- a/third_party/nix/src/libstore/globals.cc
+++ b/third_party/nix/src/libstore/globals.cc
@@ -105,7 +105,7 @@ StringSet Settings::getDefaultSystemFeatures() {
   return features;
 }
 
-const string nixVersion = PACKAGE_VERSION;
+const std::string nixVersion = PACKAGE_VERSION;
 
 template <>
 void BaseSetting<SandboxMode>::set(const std::string& str) {
diff --git a/third_party/nix/src/libstore/globals.hh b/third_party/nix/src/libstore/globals.hh
index 71bc2b1e7407..feff54879070 100644
--- a/third_party/nix/src/libstore/globals.hh
+++ b/third_party/nix/src/libstore/globals.hh
@@ -468,6 +468,6 @@ void initPlugins();
 
 void loadConfFile();
 
-extern const string nixVersion;
+extern const std::string nixVersion;
 
 }  // namespace nix
diff --git a/third_party/nix/src/libstore/http-binary-cache-store.cc b/third_party/nix/src/libstore/http-binary-cache-store.cc
index 1a46423b3542..c75d5f2860a7 100644
--- a/third_party/nix/src/libstore/http-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/http-binary-cache-store.cc
@@ -94,7 +94,7 @@ class HttpBinaryCacheStore : public BinaryCacheStore {
   void upsertFile(const std::string& path, const std::string& data,
                   const std::string& mimeType) override {
     auto req = DownloadRequest(cacheUri + "/" + path);
-    req.data = std::make_shared<string>(data);  // FIXME: inefficient
+    req.data = std::make_shared<std::string>(data);  // FIXME: inefficient
     req.mimeType = mimeType;
     try {
       getDownloader()->download(req);
diff --git a/third_party/nix/src/libstore/legacy-ssh-store.cc b/third_party/nix/src/libstore/legacy-ssh-store.cc
index 9a84e0295657..9e6870f0da6b 100644
--- a/third_party/nix/src/libstore/legacy-ssh-store.cc
+++ b/third_party/nix/src/libstore/legacy-ssh-store.cc
@@ -43,7 +43,7 @@ struct LegacySSHStore : public Store {
 
   SSHMaster master;
 
-  LegacySSHStore(const string& host, const Params& params)
+  LegacySSHStore(const std::string& host, const Params& params)
       : Store(params),
         host(host),
         connections(make_ref<Pool<Connection>>(
@@ -85,7 +85,7 @@ struct LegacySSHStore : public Store {
     return conn;
   };
 
-  string getUri() override { return uriScheme + host; }
+  std::string getUri() override { return uriScheme + host; }
 
   void queryPathInfoUncached(
       const Path& path,
@@ -176,17 +176,17 @@ struct LegacySSHStore : public Store {
     copyNAR(conn->from, sink);
   }
 
-  Path queryPathFromHashPart(const string& hashPart) override {
+  Path queryPathFromHashPart(const std::string& hashPart) override {
     unsupported("queryPathFromHashPart");
   }
 
-  Path addToStore(const string& name, const Path& srcPath, bool recursive,
+  Path addToStore(const std::string& name, const Path& srcPath, bool recursive,
                   HashType hashAlgo, PathFilter& filter,
                   RepairFlag repair) override {
     unsupported("addToStore");
   }
 
-  Path addTextToStore(const string& name, const string& s,
+  Path addTextToStore(const std::string& name, const std::string& s,
                       const PathSet& references, RepairFlag repair) override {
     unsupported("addTextToStore");
   }
diff --git a/third_party/nix/src/libstore/local-fs-store.cc b/third_party/nix/src/libstore/local-fs-store.cc
index 2120afc0ce7c..f11c84b182a6 100644
--- a/third_party/nix/src/libstore/local-fs-store.cc
+++ b/third_party/nix/src/libstore/local-fs-store.cc
@@ -79,7 +79,7 @@ void LocalFSStore::narFromPath(const Path& path, Sink& sink) {
   dumpPath(getRealStoreDir() + std::string(path, storeDir.size()), sink);
 }
 
-const string LocalFSStore::drvsLogDir = "drvs";
+const std::string LocalFSStore::drvsLogDir = "drvs";
 
 std::shared_ptr<std::string> LocalFSStore::getBuildLog(const Path& path_) {
   auto path(path_);
@@ -97,12 +97,13 @@ std::shared_ptr<std::string> LocalFSStore::getBuildLog(const Path& path_) {
     }
   }
 
-  string baseName = baseNameOf(path);
+  std::string baseName = baseNameOf(path);
 
   for (int j = 0; j < 2; j++) {
-    Path logPath = j == 0 ? fmt("%s/%s/%s/%s", logDir, drvsLogDir,
-                                string(baseName, 0, 2), string(baseName, 2))
-                          : fmt("%s/%s/%s", logDir, drvsLogDir, baseName);
+    Path logPath =
+        j == 0 ? fmt("%s/%s/%s/%s", logDir, drvsLogDir,
+                     std::string(baseName, 0, 2), std::string(baseName, 2))
+               : fmt("%s/%s/%s", logDir, drvsLogDir, baseName);
     Path logBz2Path = logPath + ".bz2";
 
     if (pathExists(logPath)) {
diff --git a/third_party/nix/src/libstore/local-store.cc b/third_party/nix/src/libstore/local-store.cc
index a89c6a79757d..84055740de2c 100644
--- a/third_party/nix/src/libstore/local-store.cc
+++ b/third_party/nix/src/libstore/local-store.cc
@@ -10,10 +10,16 @@
 #include <fcntl.h>
 #include <glog/logging.h>
 #include <grp.h>
+#include <sched.h>
+#include <sqlite3.h>
+#include <sys/ioctl.h>
+#include <sys/mount.h>
 #include <sys/select.h>
 #include <sys/stat.h>
+#include <sys/statvfs.h>
 #include <sys/time.h>
 #include <sys/types.h>
+#include <sys/xattr.h>
 #include <unistd.h>
 #include <utime.h>
 
@@ -24,13 +30,6 @@
 #include "pathlocks.hh"
 #include "worker-protocol.hh"
 
-#include <sched.h>
-#include <sys/ioctl.h>
-#include <sys/mount.h>
-#include <sys/statvfs.h>
-#include <sys/xattr.h>
-#include <sqlite3.h>
-
 namespace nix {
 
 LocalStore::LocalStore(const Params& params)
@@ -136,7 +135,7 @@ LocalStore::LocalStore(const Params& params)
       res = posix_fallocate(fd.get(), 0, settings.reservedSize);
 #endif
       if (res == -1) {
-        writeFull(fd.get(), string(settings.reservedSize, 'X'));
+        writeFull(fd.get(), std::string(settings.reservedSize, 'X'));
         [[gnu::unused]] auto res2 = ftruncate(fd.get(), settings.reservedSize);
       }
     }
@@ -295,7 +294,7 @@ std::string LocalStore::getUri() { return "local"; }
 int LocalStore::getSchema() {
   int curSchema = 0;
   if (pathExists(schemaPath)) {
-    string s = readFile(schemaPath);
+    std::string s = readFile(schemaPath);
     if (!string2Int(s, curSchema)) {
       throw Error(format("'%1%' is corrupt") % schemaPath);
     }
@@ -310,7 +309,7 @@ void LocalStore::openDB(State& state, bool create) {
   }
 
   /* Open the Nix database. */
-  string dbPath = dbDir + "/db.sqlite";
+  std::string dbPath = dbDir + "/db.sqlite";
   auto& db(state.db);
   if (sqlite3_open_v2(dbPath.c_str(), &db.db,
                       SQLITE_OPEN_READWRITE | (create ? SQLITE_OPEN_CREATE : 0),
@@ -341,20 +340,20 @@ void LocalStore::openDB(State& state, bool create) {
      should be safe enough.  If the user asks for it, don't sync at
      all.  This can cause database corruption if the system
      crashes. */
-  string syncMode = settings.fsyncMetadata ? "normal" : "off";
+  std::string syncMode = settings.fsyncMetadata ? "normal" : "off";
   db.exec("pragma synchronous = " + syncMode);
 
   /* Set the SQLite journal mode.  WAL mode is fastest, so it's the
      default. */
-  string mode = settings.useSQLiteWAL ? "wal" : "truncate";
-  string prevMode;
+  std::string mode = settings.useSQLiteWAL ? "wal" : "truncate";
+  std::string prevMode;
   {
     SQLiteStmt stmt;
     stmt.create(db, "pragma main.journal_mode;");
     if (sqlite3_step(stmt) != SQLITE_ROW) {
       throwSQLiteError(db, "querying journal mode");
     }
-    prevMode = string((const char*)sqlite3_column_text(stmt, 0));
+    prevMode = std::string((const char*)sqlite3_column_text(stmt, 0));
   }
   if (prevMode != mode &&
       sqlite3_exec(db, ("pragma main.journal_mode = " + mode + ";").c_str(),
@@ -563,9 +562,9 @@ void canonicalisePathMetaData(const Path& path, uid_t fromUid) {
 
 void LocalStore::checkDerivationOutputs(const Path& drvPath,
                                         const Derivation& drv) {
-  string drvName = storePathToName(drvPath);
+  std::string drvName = storePathToName(drvPath);
   assert(isDerivation(drvName));
-  drvName = string(drvName, 0, drvName.size() - drvExtension.size());
+  drvName = std::string(drvName, 0, drvName.size() - drvExtension.size());
 
   if (drv.isFixedOutput()) {
     auto out = drv.outputs.find("out");
@@ -843,7 +842,7 @@ StringSet LocalStore::queryDerivationOutputNames(const Path& path) {
   });
 }
 
-Path LocalStore::queryPathFromHashPart(const string& hashPart) {
+Path LocalStore::queryPathFromHashPart(const std::string& hashPart) {
   if (hashPart.size() != storePathHashLen) {
     throw Error("invalid hash part");
   }
@@ -1096,9 +1095,9 @@ void LocalStore::addToStore(const ValidPathInfo& info, Source& source,
   }
 }
 
-Path LocalStore::addToStoreFromDump(const string& dump, const string& name,
-                                    bool recursive, HashType hashAlgo,
-                                    RepairFlag repair) {
+Path LocalStore::addToStoreFromDump(const std::string& dump,
+                                    const std::string& name, bool recursive,
+                                    HashType hashAlgo, RepairFlag repair) {
   Hash h = hashString(hashAlgo, dump);
 
   Path dstPath = makeFixedOutputPath(recursive, h, name);
@@ -1155,7 +1154,7 @@ Path LocalStore::addToStoreFromDump(const string& dump, const string& name,
   return dstPath;
 }
 
-Path LocalStore::addToStore(const string& name, const Path& _srcPath,
+Path LocalStore::addToStore(const std::string& name, const Path& _srcPath,
                             bool recursive, HashType hashAlgo,
                             PathFilter& filter, RepairFlag repair) {
   Path srcPath(absPath(_srcPath));
@@ -1173,7 +1172,7 @@ Path LocalStore::addToStore(const string& name, const Path& _srcPath,
   return addToStoreFromDump(*sink.s, name, recursive, hashAlgo, repair);
 }
 
-Path LocalStore::addTextToStore(const string& name, const string& s,
+Path LocalStore::addTextToStore(const std::string& name, const std::string& s,
                                 const PathSet& references, RepairFlag repair) {
   auto hash = hashString(htSHA256, s);
   auto dstPath = makeTextPath(name, hash, references);
diff --git a/third_party/nix/src/libstore/local-store.hh b/third_party/nix/src/libstore/local-store.hh
index 1a58df81613b..c1bfc0876412 100644
--- a/third_party/nix/src/libstore/local-store.hh
+++ b/third_party/nix/src/libstore/local-store.hh
@@ -125,7 +125,7 @@ class LocalStore : public LocalFSStore {
 
   StringSet queryDerivationOutputNames(const Path& path) override;
 
-  Path queryPathFromHashPart(const string& hashPart) override;
+  Path queryPathFromHashPart(const std::string& hashPart) override;
 
   PathSet querySubstitutablePaths(const PathSet& paths) override;
 
@@ -136,7 +136,7 @@ class LocalStore : public LocalFSStore {
                   CheckSigsFlag checkSigs,
                   std::shared_ptr<FSAccessor> accessor) override;
 
-  Path addToStore(const string& name, const Path& srcPath, bool recursive,
+  Path addToStore(const std::string& name, const Path& srcPath, bool recursive,
                   HashType hashAlgo, PathFilter& filter,
                   RepairFlag repair) override;
 
@@ -144,11 +144,11 @@ class LocalStore : public LocalFSStore {
      in `dump', which is either a NAR serialisation (if recursive ==
      true) or simply the contents of a regular file (if recursive ==
      false). */
-  Path addToStoreFromDump(const string& dump, const string& name,
+  Path addToStoreFromDump(const std::string& dump, const std::string& name,
                           bool recursive = true, HashType hashAlgo = htSHA256,
                           RepairFlag repair = NoRepair);
 
-  Path addTextToStore(const string& name, const string& s,
+  Path addTextToStore(const std::string& name, const std::string& s,
                       const PathSet& references, RepairFlag repair) override;
 
   void buildPaths(const PathSet& paths, BuildMode buildMode) override;
@@ -166,7 +166,7 @@ class LocalStore : public LocalFSStore {
 
  private:
   typedef std::shared_ptr<AutoCloseFD> FDPtr;
-  typedef list<FDPtr> FDs;
+  typedef std::list<FDPtr> FDs;
 
   void findTempRoots(FDs& fds, Roots& roots, bool censor);
 
@@ -248,7 +248,7 @@ class LocalStore : public LocalFSStore {
   void deletePathRecursive(GCState& state, const Path& path);
 
   static bool isActiveTempFile(const GCState& state, const Path& path,
-                               const string& suffix);
+                               const std::string& suffix);
 
   AutoCloseFD openGCLock(LockType lockType);
 
@@ -290,7 +290,7 @@ class LocalStore : public LocalFSStore {
 };
 
 typedef std::pair<dev_t, ino_t> Inode;
-typedef set<Inode> InodesSeen;
+typedef std::set<Inode> InodesSeen;
 
 /* "Fix", or canonicalise, the meta-data of the files in a store path
    after it has been built.  In particular:
diff --git a/third_party/nix/src/libstore/machines.cc b/third_party/nix/src/libstore/machines.cc
index 5b0c7e72ddba..2f1a7289bd84 100644
--- a/third_party/nix/src/libstore/machines.cc
+++ b/third_party/nix/src/libstore/machines.cc
@@ -32,22 +32,22 @@ Machine::Machine(decltype(storeUri)& storeUri,
       mandatoryFeatures(mandatoryFeatures),
       sshPublicHostKey(sshPublicHostKey) {}
 
-bool Machine::allSupported(const std::set<string>& features) const {
+bool Machine::allSupported(const std::set<std::string>& features) const {
   return std::all_of(features.begin(), features.end(),
-                     [&](const string& feature) {
+                     [&](const std::string& feature) {
                        return (supportedFeatures.count(feature) != 0u) ||
                               (mandatoryFeatures.count(feature) != 0u);
                      });
 }
 
-bool Machine::mandatoryMet(const std::set<string>& features) const {
+bool Machine::mandatoryMet(const std::set<std::string>& features) const {
   return std::all_of(
       mandatoryFeatures.begin(), mandatoryFeatures.end(),
-      [&](const string& feature) { return features.count(feature); });
+      [&](const std::string& feature) { return features.count(feature); });
 }
 
 void parseMachines(const std::string& s, Machines& machines) {
-  for (auto line : tokenizeString<std::vector<string>>(s, "\n;")) {
+  for (auto line : tokenizeString<std::vector<std::string>>(s, "\n;")) {
     trim(line);
     line.erase(std::find(line.begin(), line.end(), '#'), line.end());
     if (line.empty()) {
@@ -67,7 +67,7 @@ void parseMachines(const std::string& s, Machines& machines) {
       continue;
     }
 
-    auto tokens = tokenizeString<std::vector<string>>(line);
+    auto tokens = tokenizeString<std::vector<std::string>>(line);
     auto sz = tokens.size();
     if (sz < 1) {
       throw FormatError("bad machine specification '%s'", line);
@@ -79,14 +79,14 @@ void parseMachines(const std::string& s, Machines& machines) {
 
     machines.emplace_back(
         tokens[0],
-        isSet(1) ? tokenizeString<std::vector<string>>(tokens[1], ",")
-                 : std::vector<string>{settings.thisSystem},
+        isSet(1) ? tokenizeString<std::vector<std::string>>(tokens[1], ",")
+                 : std::vector<std::string>{settings.thisSystem},
         isSet(2) ? tokens[2] : "", isSet(3) ? std::stoull(tokens[3]) : 1LL,
         isSet(4) ? std::stoull(tokens[4]) : 1LL,
-        isSet(5) ? tokenizeString<std::set<string>>(tokens[5], ",")
-                 : std::set<string>{},
-        isSet(6) ? tokenizeString<std::set<string>>(tokens[6], ",")
-                 : std::set<string>{},
+        isSet(5) ? tokenizeString<std::set<std::string>>(tokens[5], ",")
+                 : std::set<std::string>{},
+        isSet(6) ? tokenizeString<std::set<std::string>>(tokens[6], ",")
+                 : std::set<std::string>{},
         isSet(7) ? tokens[7] : "");
   }
 }
diff --git a/third_party/nix/src/libstore/machines.hh b/third_party/nix/src/libstore/machines.hh
index aef8054c250e..23712e676056 100644
--- a/third_party/nix/src/libstore/machines.hh
+++ b/third_party/nix/src/libstore/machines.hh
@@ -5,19 +5,19 @@
 namespace nix {
 
 struct Machine {
-  const string storeUri;
-  const std::vector<string> systemTypes;
-  const string sshKey;
+  const std::string storeUri;
+  const std::vector<std::string> systemTypes;
+  const std::string sshKey;
   const unsigned int maxJobs;
   const unsigned int speedFactor;
-  const std::set<string> supportedFeatures;
-  const std::set<string> mandatoryFeatures;
+  const std::set<std::string> supportedFeatures;
+  const std::set<std::string> mandatoryFeatures;
   const std::string sshPublicHostKey;
   bool enabled = true;
 
-  bool allSupported(const std::set<string>& features) const;
+  bool allSupported(const std::set<std::string>& features) const;
 
-  bool mandatoryMet(const std::set<string>& features) const;
+  bool mandatoryMet(const std::set<std::string>& features) const;
 
   Machine(decltype(storeUri)& storeUri, decltype(systemTypes)& systemTypes,
           decltype(sshKey)& sshKey, decltype(maxJobs) maxJobs,
diff --git a/third_party/nix/src/libstore/nar-accessor.cc b/third_party/nix/src/libstore/nar-accessor.cc
index 7f6e0377aed4..84bfb531ecd6 100644
--- a/third_party/nix/src/libstore/nar-accessor.cc
+++ b/third_party/nix/src/libstore/nar-accessor.cc
@@ -74,7 +74,7 @@ struct NarAccessor : public FSAccessor {
     void isExecutable() override { parents.top()->isExecutable = true; }
 
     void preallocateContents(unsigned long long size) override {
-      currentStart = string(s, pos, 16);
+      currentStart = std::string(s, pos, 16);
       assert(size <= std::numeric_limits<size_t>::max());
       parents.top()->size = (size_t)size;
       parents.top()->start = pos;
@@ -83,12 +83,12 @@ struct NarAccessor : public FSAccessor {
     void receiveContents(unsigned char* data, unsigned int len) override {
       // Sanity check
       if (!currentStart.empty()) {
-        assert(len < 16 || currentStart == string((char*)data, 16));
+        assert(len < 16 || currentStart == std::string((char*)data, 16));
         currentStart.clear();
       }
     }
 
-    void createSymlink(const Path& path, const string& target) override {
+    void createSymlink(const Path& path, const std::string& target) override {
       createMember(path,
                    NarMember{FSAccessor::Type::tSymlink, false, 0, 0, target});
     }
diff --git a/third_party/nix/src/libstore/nar-info.cc b/third_party/nix/src/libstore/nar-info.cc
index 91cf471554f3..5a217d1b617d 100644
--- a/third_party/nix/src/libstore/nar-info.cc
+++ b/third_party/nix/src/libstore/nar-info.cc
@@ -10,7 +10,7 @@ NarInfo::NarInfo(const Store& store, const std::string& s,
     throw Error(format("NAR info file '%1%' is corrupt") % whence);
   };
 
-  auto parseHashField = [&](const string& s) {
+  auto parseHashField = [&](const std::string& s) {
     try {
       return Hash(s);
     } catch (BadHash&) {
diff --git a/third_party/nix/src/libstore/optimise-store.cc b/third_party/nix/src/libstore/optimise-store.cc
index caeff72363a4..7217d54ca9af 100644
--- a/third_party/nix/src/libstore/optimise-store.cc
+++ b/third_party/nix/src/libstore/optimise-store.cc
@@ -83,7 +83,7 @@ Strings LocalStore::readDirectoryIgnoringInodes(const Path& path,
       continue;
     }
 
-    string name = dirent->d_name;
+    std::string name = dirent->d_name;
     if (name == "." || name == "..") {
       continue;
     }
@@ -271,7 +271,7 @@ void LocalStore::optimiseStore(OptimiseStats& stats) {
   }
 }
 
-static string showBytes(unsigned long long bytes) {
+static std::string showBytes(unsigned long long bytes) {
   return (format("%.2f MiB") % (bytes / (1024.0 * 1024.0))).str();
 }
 
diff --git a/third_party/nix/src/libstore/pathlocks.cc b/third_party/nix/src/libstore/pathlocks.cc
index eeee5ee1e9c9..642e64a62bac 100644
--- a/third_party/nix/src/libstore/pathlocks.cc
+++ b/third_party/nix/src/libstore/pathlocks.cc
@@ -73,12 +73,12 @@ bool lockFile(int fd, LockType lockType, bool wait) {
 
 PathLocks::PathLocks() : deletePaths(false) {}
 
-PathLocks::PathLocks(const PathSet& paths, const string& waitMsg)
+PathLocks::PathLocks(const PathSet& paths, const std::string& waitMsg)
     : deletePaths(false) {
   lockPaths(paths, waitMsg);
 }
 
-bool PathLocks::lockPaths(const PathSet& paths, const string& waitMsg,
+bool PathLocks::lockPaths(const PathSet& paths, const std::string& waitMsg,
                           bool wait) {
   assert(fds.empty());
 
diff --git a/third_party/nix/src/libstore/pathlocks.hh b/third_party/nix/src/libstore/pathlocks.hh
index 90184989cde3..201e3f01b4df 100644
--- a/third_party/nix/src/libstore/pathlocks.hh
+++ b/third_party/nix/src/libstore/pathlocks.hh
@@ -19,13 +19,13 @@ bool lockFile(int fd, LockType lockType, bool wait);
 class PathLocks {
  private:
   typedef std::pair<int, Path> FDPair;
-  list<FDPair> fds;
+  std::list<FDPair> fds;
   bool deletePaths;
 
  public:
   PathLocks();
-  PathLocks(const PathSet& paths, const string& waitMsg = "");
-  bool lockPaths(const PathSet& _paths, const string& waitMsg = "",
+  PathLocks(const PathSet& paths, const std::string& waitMsg = "");
+  bool lockPaths(const PathSet& _paths, const std::string& waitMsg = "",
                  bool wait = true);
   ~PathLocks();
   void unlock();
diff --git a/third_party/nix/src/libstore/profiles.cc b/third_party/nix/src/libstore/profiles.cc
index bdb90b7388f7..7c802d754935 100644
--- a/third_party/nix/src/libstore/profiles.cc
+++ b/third_party/nix/src/libstore/profiles.cc
@@ -19,17 +19,17 @@ static bool cmpGensByNumber(const Generation& a, const Generation& b) {
 
 /* Parse a generation name of the format
    `<profilename>-<number>-link'. */
-static int parseName(const string& profileName, const string& name) {
-  if (string(name, 0, profileName.size() + 1) != profileName + "-") {
+static int parseName(const std::string& profileName, const std::string& name) {
+  if (std::string(name, 0, profileName.size() + 1) != profileName + "-") {
     return -1;
   }
-  string s = string(name, profileName.size() + 1);
-  string::size_type p = s.find("-link");
-  if (p == string::npos) {
+  std::string s = std::string(name, profileName.size() + 1);
+  std::string::size_type p = s.find("-link");
+  if (p == std::string::npos) {
     return -1;
   }
   int n;
-  if (string2Int(string(s, 0, p), n) && n >= 0) {
+  if (string2Int(std::string(s, 0, p), n) && n >= 0) {
     return n;
   }
   return -1;
@@ -39,7 +39,7 @@ Generations findGenerations(const Path& profile, int& curGen) {
   Generations gens;
 
   Path profileDir = dirOf(profile);
-  string profileName = baseNameOf(profile);
+  std::string profileName = baseNameOf(profile);
 
   for (auto& i : readDirectory(profileDir)) {
     int n;
@@ -212,10 +212,10 @@ void deleteGenerationsOlderThan(const Path& profile, time_t t, bool dryRun) {
   }
 }
 
-void deleteGenerationsOlderThan(const Path& profile, const string& timeSpec,
-                                bool dryRun) {
+void deleteGenerationsOlderThan(const Path& profile,
+                                const std::string& timeSpec, bool dryRun) {
   time_t curTime = time(nullptr);
-  string strDays = string(timeSpec, 0, timeSpec.size() - 1);
+  std::string strDays = std::string(timeSpec, 0, timeSpec.size() - 1);
   int days;
 
   if (!string2Int(strDays, days) || days < 1) {
@@ -242,7 +242,7 @@ void lockProfile(PathLocks& lock, const Path& profile) {
   lock.setDeletion(true);
 }
 
-string optimisticLockProfile(const Path& profile) {
+std::string optimisticLockProfile(const Path& profile) {
   return pathExists(profile) ? readLink(profile) : "";
 }
 
diff --git a/third_party/nix/src/libstore/profiles.hh b/third_party/nix/src/libstore/profiles.hh
index ab31cc993af5..9f31083b32ee 100644
--- a/third_party/nix/src/libstore/profiles.hh
+++ b/third_party/nix/src/libstore/profiles.hh
@@ -15,7 +15,7 @@ struct Generation {
   operator bool() const { return number != -1; }
 };
 
-typedef list<Generation> Generations;
+typedef std::list<Generation> Generations;
 
 /* Returns the list of currently present generations for the specified
    profile, sorted by generation number. */
@@ -38,8 +38,8 @@ void deleteOldGenerations(const Path& profile, bool dryRun);
 
 void deleteGenerationsOlderThan(const Path& profile, time_t t, bool dryRun);
 
-void deleteGenerationsOlderThan(const Path& profile, const string& timeSpec,
-                                bool dryRun);
+void deleteGenerationsOlderThan(const Path& profile,
+                                const std::string& timeSpec, bool dryRun);
 
 void switchLink(const Path& link, Path target);
 
@@ -56,6 +56,6 @@ void lockProfile(PathLocks& lock, const Path& profile);
    generally cheap, since the build results are still in the Nix
    store.  Most of the time, only the user environment has to be
    rebuilt. */
-string optimisticLockProfile(const Path& profile);
+std::string optimisticLockProfile(const Path& profile);
 
 }  // namespace nix
diff --git a/third_party/nix/src/libstore/references.cc b/third_party/nix/src/libstore/references.cc
index c8cebaec08f3..6b9b7137c4e5 100644
--- a/third_party/nix/src/libstore/references.cc
+++ b/third_party/nix/src/libstore/references.cc
@@ -40,7 +40,7 @@ static void search(const unsigned char* s, size_t len, StringSet& hashes,
     if (!match) {
       continue;
     }
-    string ref((const char*)s + i, refLength);
+    std::string ref((const char*)s + i, refLength);
     if (hashes.find(ref) != hashes.end()) {
       DLOG(INFO) << "found reference to '" << ref << "' at offset " << i;
       seen.insert(ref);
@@ -55,7 +55,7 @@ struct RefScanSink : Sink {
   StringSet hashes;
   StringSet seen;
 
-  string tail;
+  std::string tail;
 
   RefScanSink() : hashSink(htSHA256) {}
 
@@ -68,34 +68,34 @@ void RefScanSink::operator()(const unsigned char* data, size_t len) {
   /* It's possible that a reference spans the previous and current
      fragment, so search in the concatenation of the tail of the
      previous fragment and the start of the current fragment. */
-  string s =
-      tail + string((const char*)data, len > refLength ? refLength : len);
+  std::string s =
+      tail + std::string((const char*)data, len > refLength ? refLength : len);
   search((const unsigned char*)s.data(), s.size(), hashes, seen);
 
   search(data, len, hashes, seen);
 
   size_t tailLen = len <= refLength ? len : refLength;
-  tail = string(tail, tail.size() < refLength - tailLen
-                          ? 0
-                          : tail.size() - (refLength - tailLen)) +
-         string((const char*)data + len - tailLen, tailLen);
+  tail = std::string(tail, tail.size() < refLength - tailLen
+                               ? 0
+                               : tail.size() - (refLength - tailLen)) +
+         std::string((const char*)data + len - tailLen, tailLen);
 }
 
-PathSet scanForReferences(const string& path, const PathSet& refs,
+PathSet scanForReferences(const std::string& path, const PathSet& refs,
                           HashResult& hash) {
   RefScanSink sink;
-  std::map<string, Path> backMap;
+  std::map<std::string, Path> backMap;
 
   /* For efficiency (and a higher hit rate), just search for the
      hash part of the file name.  (This assumes that all references
      have the form `HASH-bla'). */
   for (auto& i : refs) {
-    string baseName = baseNameOf(i);
-    string::size_type pos = baseName.find('-');
-    if (pos == string::npos) {
+    std::string baseName = baseNameOf(i);
+    std::string::size_type pos = baseName.find('-');
+    if (pos == std::string::npos) {
       throw Error(format("bad reference '%1%'") % i);
     }
-    string s = string(baseName, 0, pos);
+    std::string s = std::string(baseName, 0, pos);
     assert(s.size() == refLength);
     assert(backMap.find(s) == backMap.end());
     // parseHash(htSHA256, s);
@@ -109,7 +109,7 @@ PathSet scanForReferences(const string& path, const PathSet& refs,
   /* Map the hashes found back to their store paths. */
   PathSet found;
   for (auto& i : sink.seen) {
-    std::map<string, Path>::iterator j;
+    std::map<std::string, Path>::iterator j;
     if ((j = backMap.find(i)) == backMap.end()) {
       abort();
     }
diff --git a/third_party/nix/src/libstore/remote-store.cc b/third_party/nix/src/libstore/remote-store.cc
index cc6f6ebae993..c5d1dac6cb6c 100644
--- a/third_party/nix/src/libstore/remote-store.cc
+++ b/third_party/nix/src/libstore/remote-store.cc
@@ -102,7 +102,7 @@ ref<RemoteStore::Connection> UDSRemoteStore::openConnection() {
   }
   closeOnExec(conn->fd.get());
 
-  string socketPath = path ? *path : settings.nixDaemonSocketFile;
+  std::string socketPath = path ? *path : settings.nixDaemonSocketFile;
 
   struct sockaddr_un addr;
   addr.sun_family = AF_UNIX;
@@ -412,7 +412,7 @@ PathSet RemoteStore::queryDerivationOutputNames(const Path& path) {
   return readStrings<PathSet>(conn->from);
 }
 
-Path RemoteStore::queryPathFromHashPart(const string& hashPart) {
+Path RemoteStore::queryPathFromHashPart(const std::string& hashPart) {
   auto conn(getConnection());
   conn->to << wopQueryPathFromHashPart << hashPart;
   conn.processStderr();
@@ -460,7 +460,7 @@ void RemoteStore::addToStore(const ValidPathInfo& info, Source& source,
   }
 }
 
-Path RemoteStore::addToStore(const string& name, const Path& _srcPath,
+Path RemoteStore::addToStore(const std::string& name, const Path& _srcPath,
                              bool recursive, HashType hashAlgo,
                              PathFilter& filter, RepairFlag repair) {
   if (repair != 0u) {
@@ -503,7 +503,7 @@ Path RemoteStore::addToStore(const string& name, const Path& _srcPath,
   return readStorePath(*this, conn->from);
 }
 
-Path RemoteStore::addTextToStore(const string& name, const string& s,
+Path RemoteStore::addTextToStore(const std::string& name, const std::string& s,
                                  const PathSet& references, RepairFlag repair) {
   if (repair != 0u) {
     throw Error(
@@ -537,7 +537,7 @@ void RemoteStore::buildPaths(const PathSet& drvPaths, BuildMode buildMode) {
        identifiers. */
     PathSet drvPaths2;
     for (auto& i : drvPaths) {
-      drvPaths2.insert(string(i, 0, i.find('!')));
+      drvPaths2.insert(std::string(i, 0, i.find('!')));
     }
     conn->to << drvPaths2;
   }
@@ -692,7 +692,7 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink* sink,
     auto msg = readNum<uint64_t>(from);
 
     if (msg == STDERR_WRITE) {
-      string s = readString(from);
+      std::string s = readString(from);
       if (sink == nullptr) {
         throw Error("no sink");
       }
@@ -710,7 +710,7 @@ std::exception_ptr RemoteStore::Connection::processStderr(Sink* sink,
     }
 
     else if (msg == STDERR_ERROR) {
-      string error = readString(from);
+      std::string error = readString(from);
       unsigned int status = readInt(from);
       return std::make_exception_ptr(Error(status, error));
     }
diff --git a/third_party/nix/src/libstore/remote-store.hh b/third_party/nix/src/libstore/remote-store.hh
index dc44cd32ac47..e61e72892c34 100644
--- a/third_party/nix/src/libstore/remote-store.hh
+++ b/third_party/nix/src/libstore/remote-store.hh
@@ -52,7 +52,7 @@ class RemoteStore : public virtual Store {
 
   StringSet queryDerivationOutputNames(const Path& path) override;
 
-  Path queryPathFromHashPart(const string& hashPart) override;
+  Path queryPathFromHashPart(const std::string& hashPart) override;
 
   PathSet querySubstitutablePaths(const PathSet& paths) override;
 
@@ -63,12 +63,12 @@ class RemoteStore : public virtual Store {
                   CheckSigsFlag checkSigs,
                   std::shared_ptr<FSAccessor> accessor) override;
 
-  Path addToStore(const string& name, const Path& srcPath,
+  Path addToStore(const std::string& name, const Path& srcPath,
                   bool recursive = true, HashType hashAlgo = htSHA256,
                   PathFilter& filter = defaultPathFilter,
                   RepairFlag repair = NoRepair) override;
 
-  Path addTextToStore(const string& name, const string& s,
+  Path addTextToStore(const std::string& name, const std::string& s,
                       const PathSet& references, RepairFlag repair) override;
 
   void buildPaths(const PathSet& paths, BuildMode buildMode) override;
diff --git a/third_party/nix/src/libstore/s3-binary-cache-store.cc b/third_party/nix/src/libstore/s3-binary-cache-store.cc
index df3afab3cf32..2b25fd874437 100644
--- a/third_party/nix/src/libstore/s3-binary-cache-store.cc
+++ b/third_party/nix/src/libstore/s3-binary-cache-store.cc
@@ -77,8 +77,8 @@ static void initAWS() {
   });
 }
 
-S3Helper::S3Helper(const string& profile, const string& region,
-                   const string& scheme, const string& endpoint)
+S3Helper::S3Helper(const std::string& profile, const std::string& region,
+                   const std::string& scheme, const std::string& endpoint)
     : config(makeConfig(region, scheme, endpoint)),
       client(make_ref<Aws::S3::S3Client>(
           profile == ""
@@ -114,7 +114,8 @@ class RetryStrategy : public Aws::Client::DefaultRetryStrategy {
 };
 
 ref<Aws::Client::ClientConfiguration> S3Helper::makeConfig(
-    const string& region, const string& scheme, const string& endpoint) {
+    const std::string& region, const std::string& scheme,
+    const std::string& endpoint) {
   initAWS();
   auto res = make_ref<Aws::Client::ClientConfiguration>();
   res->region = region;
diff --git a/third_party/nix/src/libstore/sqlite.cc b/third_party/nix/src/libstore/sqlite.cc
index 2dea952d0275..dbdaa29d4fd9 100644
--- a/third_party/nix/src/libstore/sqlite.cc
+++ b/third_party/nix/src/libstore/sqlite.cc
@@ -54,7 +54,7 @@ void SQLite::exec(const std::string& stmt) {
   });
 }
 
-void SQLiteStmt::create(sqlite3* db, const string& sql) {
+void SQLiteStmt::create(sqlite3* db, const std::string& sql) {
   checkInterrupt();
   assert(!stmt);
   if (sqlite3_prepare_v2(db, sql.c_str(), -1, &stmt, nullptr) != SQLITE_OK) {
diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc
index 50e9b3b6ea86..e6891395cdc5 100644
--- a/third_party/nix/src/libstore/store-api.cc
+++ b/third_party/nix/src/libstore/store-api.cc
@@ -48,7 +48,7 @@ Path Store::followLinksToStore(const Path& _path) const {
     if (!isLink(path)) {
       break;
     }
-    string target = readLink(path);
+    std::string target = readLink(path);
     path = absPath(target, dirOf(path));
   }
   if (!isInStore(path)) {
@@ -61,22 +61,23 @@ Path Store::followLinksToStorePath(const Path& path) const {
   return toStorePath(followLinksToStore(path));
 }
 
-string storePathToName(const Path& path) {
+std::string storePathToName(const Path& path) {
   auto base = baseNameOf(path);
   assert(base.size() == storePathHashLen ||
          (base.size() > storePathHashLen && base[storePathHashLen] == '-'));
-  return base.size() == storePathHashLen ? ""
-                                         : string(base, storePathHashLen + 1);
+  return base.size() == storePathHashLen
+             ? ""
+             : std::string(base, storePathHashLen + 1);
 }
 
-string storePathToHash(const Path& path) {
+std::string storePathToHash(const Path& path) {
   auto base = baseNameOf(path);
   assert(base.size() >= storePathHashLen);
-  return string(base, 0, storePathHashLen);
+  return std::string(base, 0, storePathHashLen);
 }
 
-void checkStoreName(const string& name) {
-  string validChars = "+-._?=";
+void checkStoreName(const std::string& name) {
+  std::string validChars = "+-._?=";
 
   auto baseError =
       format(
@@ -90,7 +91,7 @@ void checkStoreName(const string& name) {
 
   /* Disallow names starting with a dot for possible security
      reasons (e.g., "." and ".."). */
-  if (string(name, 0, 1) == ".") {
+  if (std::string(name, 0, 1) == ".") {
     throw Error(baseError % "it is illegal to start the name with a period");
   }
   /* Disallow names longer than 211 characters. ext4’s max is 256,
@@ -100,7 +101,7 @@ void checkStoreName(const string& name) {
   }
   for (auto& i : name) {
     if (!((i >= 'A' && i <= 'Z') || (i >= 'a' && i <= 'z') ||
-          (i >= '0' && i <= '9') || validChars.find(i) != string::npos)) {
+          (i >= '0' && i <= '9') || validChars.find(i) != std::string::npos)) {
       throw Error(baseError % (format("the '%1%' character is invalid") % i));
     }
   }
@@ -176,10 +177,11 @@ void checkStoreName(const string& name) {
    "source:".
 */
 
-Path Store::makeStorePath(const string& type, const Hash& hash,
-                          const string& name) const {
+Path Store::makeStorePath(const std::string& type, const Hash& hash,
+                          const std::string& name) const {
   /* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
-  string s = type + ":" + hash.to_string(Base16) + ":" + storeDir + ":" + name;
+  std::string s =
+      type + ":" + hash.to_string(Base16) + ":" + storeDir + ":" + name;
 
   checkStoreName(name);
 
@@ -188,31 +190,32 @@ Path Store::makeStorePath(const string& type, const Hash& hash,
          "-" + name;
 }
 
-Path Store::makeOutputPath(const string& id, const Hash& hash,
-                           const string& name) const {
+Path Store::makeOutputPath(const std::string& id, const Hash& hash,
+                           const std::string& name) const {
   return makeStorePath("output:" + id, hash,
                        name + (id == "out" ? "" : "-" + id));
 }
 
 Path Store::makeFixedOutputPath(bool recursive, const Hash& hash,
-                                const string& name) const {
+                                const std::string& name) const {
   return hash.type == htSHA256 && recursive
              ? makeStorePath("source", hash, name)
              : makeStorePath(
                    "output:out",
-                   hashString(htSHA256,
-                              "fixed:out:" + (recursive ? (string) "r:" : "") +
-                                  hash.to_string(Base16) + ":"),
+                   hashString(
+                       htSHA256,
+                       "fixed:out:" + (recursive ? (std::string) "r:" : "") +
+                           hash.to_string(Base16) + ":"),
                    name);
 }
 
-Path Store::makeTextPath(const string& name, const Hash& hash,
+Path Store::makeTextPath(const std::string& name, const Hash& hash,
                          const PathSet& references) const {
   assert(hash.type == htSHA256);
   /* Stuff the references (if any) into the type.  This is a bit
      hacky, but we can't put them in `s' since that would be
      ambiguous. */
-  string type = "text";
+  std::string type = "text";
   for (auto& i : references) {
     type += ":";
     type += i;
@@ -220,7 +223,7 @@ Path Store::makeTextPath(const string& name, const Hash& hash,
   return makeStorePath(type, hash, name);
 }
 
-std::pair<Path, Hash> Store::computeStorePathForPath(const string& name,
+std::pair<Path, Hash> Store::computeStorePathForPath(const std::string& name,
                                                      const Path& srcPath,
                                                      bool recursive,
                                                      HashType hashAlgo,
@@ -231,7 +234,8 @@ std::pair<Path, Hash> Store::computeStorePathForPath(const string& name,
   return std::pair<Path, Hash>(dstPath, h);
 }
 
-Path Store::computeStorePathForText(const string& name, const string& s,
+Path Store::computeStorePathForText(const std::string& name,
+                                    const std::string& s,
                                     const PathSet& references) const {
   return makeTextPath(name, hashString(htSHA256, s), references);
 }
@@ -428,9 +432,9 @@ PathSet Store::queryValidPaths(const PathSet& paths,
 /* Return a string accepted by decodeValidPathInfo() that
    registers the specified paths as valid.  Note: it's the
    responsibility of the caller to provide a closure. */
-string Store::makeValidityRegistration(const PathSet& paths, bool showDerivers,
-                                       bool showHash) {
-  string s = s;
+std::string Store::makeValidityRegistration(const PathSet& paths,
+                                            bool showDerivers, bool showHash) {
+  std::string s = s;
 
   for (auto& i : paths) {
     s += i + "\n";
@@ -710,7 +714,7 @@ ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven) {
     return info;
   }
   if (hashGiven) {
-    string s;
+    std::string s;
     getline(str, s);
     info.narHash = Hash(s, htSHA256);
     getline(str, s);
@@ -719,7 +723,7 @@ ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven) {
     }
   }
   getline(str, info.deriver);
-  string s;
+  std::string s;
   int n;
   getline(str, s);
   if (!string2Int(s, n)) {
@@ -735,8 +739,8 @@ ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven) {
   return info;
 }
 
-string showPaths(const PathSet& paths) {
-  string s;
+std::string showPaths(const PathSet& paths) {
+  std::string s;
   for (auto& i : paths) {
     if (!s.empty()) {
       s += ", ";
diff --git a/third_party/nix/src/libstore/store-api.hh b/third_party/nix/src/libstore/store-api.hh
index 242a3e65621e..cf2520c6ca98 100644
--- a/third_party/nix/src/libstore/store-api.hh
+++ b/third_party/nix/src/libstore/store-api.hh
@@ -18,12 +18,14 @@
 
 namespace nix {
 
-MakeError(SubstError, Error)
-    MakeError(BuildError, Error) /* denotes a permanent build failure */
-    MakeError(InvalidPath, Error) MakeError(Unsupported, Error)
-        MakeError(SubstituteGone, Error) MakeError(SubstituterDisabled, Error)
-
-            struct BasicDerivation;
+MakeError(SubstError, Error);
+MakeError(BuildError, Error); /* denotes a permanent build failure */
+MakeError(InvalidPath, Error);
+MakeError(Unsupported, Error);
+MakeError(SubstituteGone, Error);
+MakeError(SubstituterDisabled, Error);
+
+struct BasicDerivation;
 struct Derivation;
 class FSAccessor;
 class NarInfoDiskCache;
@@ -175,7 +177,7 @@ struct ValidPathInfo {
   virtual ~ValidPathInfo() {}
 };
 
-typedef list<ValidPathInfo> ValidPathInfos;
+typedef std::list<ValidPathInfo> ValidPathInfos;
 
 enum BuildMode { bmNormal, bmRepair, bmCheck };
 
@@ -274,23 +276,23 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
   Path followLinksToStorePath(const Path& path) const;
 
   /* Constructs a unique store path name. */
-  Path makeStorePath(const string& type, const Hash& hash,
-                     const string& name) const;
+  Path makeStorePath(const std::string& type, const Hash& hash,
+                     const std::string& name) const;
 
-  Path makeOutputPath(const string& id, const Hash& hash,
-                      const string& name) const;
+  Path makeOutputPath(const std::string& id, const Hash& hash,
+                      const std::string& name) const;
 
   Path makeFixedOutputPath(bool recursive, const Hash& hash,
-                           const string& name) const;
+                           const std::string& name) const;
 
-  Path makeTextPath(const string& name, const Hash& hash,
+  Path makeTextPath(const std::string& name, const Hash& hash,
                     const PathSet& references) const;
 
   /* This is the preparatory part of addToStore(); it computes the
      store path to which srcPath is to be copied.  Returns the store
      path and the cryptographic hash of the contents of srcPath. */
   std::pair<Path, Hash> computeStorePathForPath(
-      const string& name, const Path& srcPath, bool recursive = true,
+      const std::string& name, const Path& srcPath, bool recursive = true,
       HashType hashAlgo = htSHA256,
       PathFilter& filter = defaultPathFilter) const;
 
@@ -308,7 +310,7 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
      simply yield a different store path, so other users wouldn't be
      affected), but it has some backwards compatibility issues (the
      hashing scheme changes), so I'm not doing that for now. */
-  Path computeStorePathForText(const string& name, const string& s,
+  Path computeStorePathForText(const std::string& name, const std::string& s,
                                const PathSet& references) const;
 
   /* Check whether a path is valid. */
@@ -368,7 +370,7 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
 
   /* Query the full store path given the hash part of a valid store
      path, or "" if the path doesn't exist. */
-  virtual Path queryPathFromHashPart(const string& hashPart) = 0;
+  virtual Path queryPathFromHashPart(const std::string& hashPart) = 0;
 
   /* Query which of the given paths have substitutes. */
   virtual PathSet querySubstitutablePaths(const PathSet& paths) { return {}; };
@@ -400,14 +402,14 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
      validity the resulting path.  The resulting path is returned.
      The function object `filter' can be used to exclude files (see
      libutil/archive.hh). */
-  virtual Path addToStore(const string& name, const Path& srcPath,
+  virtual Path addToStore(const std::string& name, const Path& srcPath,
                           bool recursive = true, HashType hashAlgo = htSHA256,
                           PathFilter& filter = defaultPathFilter,
                           RepairFlag repair = NoRepair) = 0;
 
   /* Like addToStore, but the contents written to the output path is
      a regular file containing the given string. */
-  virtual Path addTextToStore(const string& name, const string& s,
+  virtual Path addTextToStore(const std::string& name, const std::string& s,
                               const PathSet& references,
                               RepairFlag repair = NoRepair) = 0;
 
@@ -484,8 +486,8 @@ class Store : public std::enable_shared_from_this<Store>, public Config {
   /* Return a string representing information about the path that
      can be loaded into the database using `nix-store --load-db' or
      `nix-store --register-validity'. */
-  string makeValidityRegistration(const PathSet& paths, bool showDerivers,
-                                  bool showHash);
+  std::string makeValidityRegistration(const PathSet& paths, bool showDerivers,
+                                       bool showHash);
 
   /* Write a JSON representation of store path metadata, such as the
      hash and the references. If ‘includeImpureInfo’ is true,
@@ -637,7 +639,7 @@ class LocalFSStore : public virtual Store {
       rootDir != "" ? rootDir + "/nix/var/log/nix" : settings.nixLogDir, "log",
       "directory where Nix will store state"};
 
-  const static string drvsLogDir;
+  const static std::string drvsLogDir;
 
   LocalFSStore(const Params& params);
 
@@ -660,15 +662,15 @@ class LocalFSStore : public virtual Store {
 };
 
 /* Extract the name part of the given store path. */
-string storePathToName(const Path& path);
+std::string storePathToName(const Path& path);
 
 /* Extract the hash part of the given store path. */
-string storePathToHash(const Path& path);
+std::string storePathToHash(const Path& path);
 
 /* Check whether ‘name’ is a valid store path name part, i.e. contains
    only the characters [a-zA-Z0-9\+\-\.\_\?\=] and doesn't start with
    a dot. */
-void checkStoreName(const string& name);
+void checkStoreName(const std::string& name);
 
 /* Copy a path from one store to another. */
 void copyStorePath(ref<Store> srcStore, const ref<Store>& dstStore,
@@ -756,7 +758,7 @@ struct RegisterStoreImplementation {
 
 /* Display a set of paths in human-readable form (i.e., between quotes
    and separated by commas). */
-string showPaths(const PathSet& paths);
+std::string showPaths(const PathSet& paths);
 
 ValidPathInfo decodeValidPathInfo(std::istream& str, bool hashGiven = false);