about summary refs log tree commit diff
path: root/third_party/nix/src/libutil
diff options
context:
space:
mode:
Diffstat (limited to 'third_party/nix/src/libutil')
-rw-r--r--third_party/nix/src/libutil/archive.cc30
-rw-r--r--third_party/nix/src/libutil/archive.hh2
-rw-r--r--third_party/nix/src/libutil/args.cc14
-rw-r--r--third_party/nix/src/libutil/args.hh4
-rw-r--r--third_party/nix/src/libutil/config.cc14
-rw-r--r--third_party/nix/src/libutil/hash.cc28
-rw-r--r--third_party/nix/src/libutil/hash.hh10
-rw-r--r--third_party/nix/src/libutil/serialise.cc6
-rw-r--r--third_party/nix/src/libutil/serialise.hh12
-rw-r--r--third_party/nix/src/libutil/types.hh26
-rw-r--r--third_party/nix/src/libutil/util.cc121
-rw-r--r--third_party/nix/src/libutil/util.hh79
-rw-r--r--third_party/nix/src/libutil/xml-writer.cc7
-rw-r--r--third_party/nix/src/libutil/xml-writer.hh10
14 files changed, 183 insertions, 180 deletions
diff --git a/third_party/nix/src/libutil/archive.cc b/third_party/nix/src/libutil/archive.cc
index 32bad07f22..f78727c5fb 100644
--- a/third_party/nix/src/libutil/archive.cc
+++ b/third_party/nix/src/libutil/archive.cc
@@ -38,7 +38,7 @@ static GlobalConfig::Register r1(&archiveSettings);
 
 const std::string narVersionMagic1 = "nix-archive-1";
 
-static string caseHackSuffix = "~nix~case~hack~";
+static std::string caseHackSuffix = "~nix~case~hack~";
 
 PathFilter defaultPathFilter = [](const Path& /*unused*/) { return true; };
 
@@ -89,12 +89,12 @@ static void dump(const Path& path, Sink& sink, PathFilter& filter) {
 
     /* If we're on a case-insensitive system like macOS, undo
        the case hack applied by restorePath(). */
-    std::map<string, string> unhacked;
+    std::map<std::string, std::string> unhacked;
     for (auto& i : readDirectory(path)) {
       if (archiveSettings.useCaseHack) {
-        string name(i.name);
+        std::string name(i.name);
         size_t pos = i.name.find(caseHackSuffix);
-        if (pos != string::npos) {
+        if (pos != std::string::npos) {
           DLOG(INFO) << "removing case hack suffix from " << path << "/"
                      << i.name;
 
@@ -145,7 +145,7 @@ void dumpString(const std::string& s, Sink& sink) {
        << "contents" << s << ")";
 }
 
-static SerialisationError badArchive(const string& s) {
+static SerialisationError badArchive(const std::string& s) {
   return SerialisationError("bad archive: " + s);
 }
 
@@ -182,13 +182,13 @@ static void parseContents(ParseSink& sink, Source& source, const Path& path) {
 }
 
 struct CaseInsensitiveCompare {
-  bool operator()(const string& a, const string& b) const {
+  bool operator()(const std::string& a, const std::string& b) const {
     return strcasecmp(a.c_str(), b.c_str()) < 0;
   }
 };
 
 static void parse(ParseSink& sink, Source& source, const Path& path) {
-  string s;
+  std::string s;
 
   s = readString(source);
   if (s != "(") {
@@ -212,7 +212,7 @@ static void parse(ParseSink& sink, Source& source, const Path& path) {
       if (type != tpUnknown) {
         throw badArchive("multiple type fields");
       }
-      string t = readString(source);
+      std::string t = readString(source);
 
       if (t == "regular") {
         type = tpRegular;
@@ -247,8 +247,8 @@ static void parse(ParseSink& sink, Source& source, const Path& path) {
     }
 
     else if (s == "entry" && type == tpDirectory) {
-      string name;
-      string prevName;
+      std::string name;
+      std::string prevName;
 
       s = readString(source);
       if (s != "(") {
@@ -266,8 +266,8 @@ static void parse(ParseSink& sink, Source& source, const Path& path) {
         if (s == "name") {
           name = readString(source);
           if (name.empty() || name == "." || name == ".." ||
-              name.find('/') != string::npos ||
-              name.find((char)0) != string::npos) {
+              name.find('/') != std::string::npos ||
+              name.find((char)0) != std::string::npos) {
             throw Error(format("NAR contains invalid file name '%1%'") % name);
           }
           if (name <= prevName) {
@@ -297,7 +297,7 @@ static void parse(ParseSink& sink, Source& source, const Path& path) {
     }
 
     else if (s == "target" && type == tpSymlink) {
-      string target = readString(source);
+      std::string target = readString(source);
       sink.createSymlink(path, target);
     }
 
@@ -308,7 +308,7 @@ static void parse(ParseSink& sink, Source& source, const Path& path) {
 }
 
 void parseDump(ParseSink& sink, Source& source) {
-  string version;
+  std::string version;
   try {
     version = readString(source, narVersionMagic1.size());
   } catch (SerialisationError& e) {
@@ -369,7 +369,7 @@ struct RestoreSink : ParseSink {
     writeFull(fd.get(), data, len);
   }
 
-  void createSymlink(const Path& path, const string& target) override {
+  void createSymlink(const Path& path, const std::string& target) override {
     Path p = dstPath + path;
     nix::createSymlink(target, p);
   }
diff --git a/third_party/nix/src/libutil/archive.hh b/third_party/nix/src/libutil/archive.hh
index 9a656edae4..0afa8893ef 100644
--- a/third_party/nix/src/libutil/archive.hh
+++ b/third_party/nix/src/libutil/archive.hh
@@ -56,7 +56,7 @@ struct ParseSink {
   virtual void preallocateContents(unsigned long long size){};
   virtual void receiveContents(unsigned char* data, unsigned int len){};
 
-  virtual void createSymlink(const Path& path, const string& target){};
+  virtual void createSymlink(const Path& path, const std::string& target){};
 };
 
 struct TeeSink : ParseSink {
diff --git a/third_party/nix/src/libutil/args.cc b/third_party/nix/src/libutil/args.cc
index 48fa715fdf..4e7bcb3ae7 100644
--- a/third_party/nix/src/libutil/args.cc
+++ b/third_party/nix/src/libutil/args.cc
@@ -27,14 +27,14 @@ void Args::parseCmdline(const Strings& _cmdline) {
        `-j3` -> `-j 3`). */
     if (!dashDash && arg.length() > 2 && arg[0] == '-' && arg[1] != '-' &&
         (isalpha(arg[1]) != 0)) {
-      *pos = (string) "-" + arg[1];
+      *pos = (std::string) "-" + arg[1];
       auto next = pos;
       ++next;
       for (unsigned int j = 2; j < arg.length(); j++) {
         if (isalpha(arg[j]) != 0) {
-          cmdline.insert(next, (string) "-" + arg[j]);
+          cmdline.insert(next, (std::string) "-" + arg[j]);
         } else {
-          cmdline.insert(next, string(arg, j));
+          cmdline.insert(next, std::string(arg, j));
           break;
         }
       }
@@ -59,7 +59,7 @@ void Args::parseCmdline(const Strings& _cmdline) {
   processArgs(pendingArgs, true);
 }
 
-void Args::printHelp(const string& programName, std::ostream& out) {
+void Args::printHelp(const std::string& programName, std::ostream& out) {
   std::cout << "Usage: " << programName << " <FLAGS>...";
   for (auto& exp : expectedArgs) {
     std::cout << renderLabels({exp.label});
@@ -121,15 +121,15 @@ bool Args::processFlag(Strings::iterator& pos, Strings::iterator end) {
     return true;
   };
 
-  if (string(*pos, 0, 2) == "--") {
-    auto i = longFlags.find(string(*pos, 2));
+  if (std::string(*pos, 0, 2) == "--") {
+    auto i = longFlags.find(std::string(*pos, 2));
     if (i == longFlags.end()) {
       return false;
     }
     return process("--" + i->first, *i->second);
   }
 
-  if (string(*pos, 0, 1) == "-" && pos->size() == 2) {
+  if (std::string(*pos, 0, 1) == "-" && pos->size() == 2) {
     auto c = (*pos)[1];
     auto i = shortFlags.find(c);
     if (i == shortFlags.end()) {
diff --git a/third_party/nix/src/libutil/args.hh b/third_party/nix/src/libutil/args.hh
index 20233d3534..20a6379fec 100644
--- a/third_party/nix/src/libutil/args.hh
+++ b/third_party/nix/src/libutil/args.hh
@@ -18,7 +18,7 @@ class Args {
      wrong. */
   void parseCmdline(const Strings& cmdline);
 
-  virtual void printHelp(const string& programName, std::ostream& out);
+  virtual void printHelp(const std::string& programName, std::ostream& out);
 
   virtual std::string description() { return ""; }
 
@@ -187,7 +187,7 @@ class Args {
   }
 
   /* Expect a string argument. */
-  void expectArg(const std::string& label, string* dest,
+  void expectArg(const std::string& label, std::string* dest,
                  bool optional = false) {
     expectedArgs.push_back(
         ExpectedArg{label, 1, optional,
diff --git a/third_party/nix/src/libutil/config.cc b/third_party/nix/src/libutil/config.cc
index 828ee1811b..c7c952abf1 100644
--- a/third_party/nix/src/libutil/config.cc
+++ b/third_party/nix/src/libutil/config.cc
@@ -82,23 +82,23 @@ void Config::getSettings(std::map<std::string, SettingInfo>& res,
 
 void AbstractConfig::applyConfigFile(const Path& path) {
   try {
-    string contents = readFile(path);
+    std::string contents = readFile(path);
 
     unsigned int pos = 0;
 
     while (pos < contents.size()) {
-      string line;
+      std::string line;
       while (pos < contents.size() && contents[pos] != '\n') {
         line += contents[pos++];
       }
       pos++;
 
-      string::size_type hash = line.find('#');
-      if (hash != string::npos) {
-        line = string(line, 0, hash);
+      std::string::size_type hash = line.find('#');
+      if (hash != std::string::npos) {
+        line = std::string(line, 0, hash);
       }
 
-      auto tokens = tokenizeString<vector<string> >(line);
+      auto tokens = tokenizeString<std::vector<std::string> >(line);
       if (tokens.empty()) {
         continue;
       }
@@ -136,7 +136,7 @@ void AbstractConfig::applyConfigFile(const Path& path) {
                          path);
       }
 
-      string name = tokens[0];
+      std::string name = tokens[0];
 
       auto i = tokens.begin();
       advance(i, 2);
diff --git a/third_party/nix/src/libutil/hash.cc b/third_party/nix/src/libutil/hash.cc
index 81d8628e97..07a9730551 100644
--- a/third_party/nix/src/libutil/hash.cc
+++ b/third_party/nix/src/libutil/hash.cc
@@ -63,26 +63,26 @@ bool Hash::operator<(const Hash& h) const {
   return false;
 }
 
-const string base16Chars = "0123456789abcdef";
+const std::string base16Chars = "0123456789abcdef";
 
-static string printHash16(const Hash& hash) {
+static std::string printHash16(const Hash& hash) {
   char buf[hash.hashSize * 2];
   for (unsigned int i = 0; i < hash.hashSize; i++) {
     buf[i * 2] = base16Chars[hash.hash[i] >> 4];
     buf[i * 2 + 1] = base16Chars[hash.hash[i] & 0x0f];
   }
-  return string(buf, hash.hashSize * 2);
+  return std::string(buf, hash.hashSize * 2);
 }
 
 // omitted: E O U T
-const string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
+const std::string base32Chars = "0123456789abcdfghijklmnpqrsvwxyz";
 
-static string printHash32(const Hash& hash) {
+static std::string printHash32(const Hash& hash) {
   assert(hash.hashSize);
   size_t len = hash.base32Len();
   assert(len);
 
-  string s;
+  std::string s;
   s.reserve(len);
 
   for (int n = (int)len - 1; n >= 0; n--) {
@@ -98,7 +98,7 @@ static string printHash32(const Hash& hash) {
   return s;
 }
 
-string printHash16or32(const Hash& hash) {
+std::string printHash16or32(const Hash& hash) {
   return hash.to_string(hash.type == htMD5 ? Base16 : Base32, false);
 }
 
@@ -128,17 +128,17 @@ Hash::Hash(const std::string& s, HashType type) : type(type) {
   bool isSRI = false;
 
   auto sep = s.find(':');
-  if (sep == string::npos) {
+  if (sep == std::string::npos) {
     sep = s.find('-');
-    if (sep != string::npos) {
+    if (sep != std::string::npos) {
       isSRI = true;
     } else if (type == htUnknown) {
       throw BadHash("hash '%s' does not include a type", s);
     }
   }
 
-  if (sep != string::npos) {
-    string hts = string(s, 0, sep);
+  if (sep != std::string::npos) {
+    std::string hts = std::string(s, 0, sep);
     this->type = parseHashType(hts);
     if (this->type == htUnknown) {
       throw BadHash("unknown hash type '%s'", hts);
@@ -259,7 +259,7 @@ static void finish(HashType ht, Ctx& ctx, unsigned char* hash) {
   }
 }
 
-Hash hashString(HashType ht, const string& s) {
+Hash hashString(HashType ht, const std::string& s) {
   Ctx ctx;
   Hash hash(ht);
   start(ht, ctx);
@@ -338,7 +338,7 @@ Hash compressHash(const Hash& hash, unsigned int newSize) {
   return h;
 }
 
-HashType parseHashType(const string& s) {
+HashType parseHashType(const std::string& s) {
   if (s == "md5") {
     return htMD5;
   }
@@ -353,7 +353,7 @@ HashType parseHashType(const string& s) {
   }
 }
 
-string printHashType(HashType ht) {
+std::string printHashType(HashType ht) {
   if (ht == htMD5) {
     return "md5";
   }
diff --git a/third_party/nix/src/libutil/hash.hh b/third_party/nix/src/libutil/hash.hh
index a9002023fa..f9c63c155e 100644
--- a/third_party/nix/src/libutil/hash.hh
+++ b/third_party/nix/src/libutil/hash.hh
@@ -14,7 +14,7 @@ const int sha1HashSize = 20;
 const int sha256HashSize = 32;
 const int sha512HashSize = 64;
 
-extern const string base32Chars;
+extern const std::string base32Chars;
 
 enum Base : int { Base64, Base32, Base16, SRI };
 
@@ -68,10 +68,10 @@ struct Hash {
 };
 
 /* Print a hash in base-16 if it's MD5, or base-32 otherwise. */
-string printHash16or32(const Hash& hash);
+std::string printHash16or32(const Hash& hash);
 
 /* Compute the hash of the given string. */
-Hash hashString(HashType ht, const string& s);
+Hash hashString(HashType ht, const std::string& s);
 
 /* Compute the hash of the given file. */
 Hash hashFile(HashType ht, const Path& path);
@@ -87,10 +87,10 @@ HashResult hashPath(HashType ht, const Path& path,
 Hash compressHash(const Hash& hash, unsigned int newSize);
 
 /* Parse a string representing a hash type. */
-HashType parseHashType(const string& s);
+HashType parseHashType(const std::string& s);
 
 /* And the reverse. */
-string printHashType(HashType ht);
+std::string printHashType(HashType ht);
 
 union Ctx;
 
diff --git a/third_party/nix/src/libutil/serialise.cc b/third_party/nix/src/libutil/serialise.cc
index 34af4e840a..52f0b55426 100644
--- a/third_party/nix/src/libutil/serialise.cc
+++ b/third_party/nix/src/libutil/serialise.cc
@@ -223,7 +223,7 @@ void writeString(const unsigned char* buf, size_t len, Sink& sink) {
   writePadding(len, sink);
 }
 
-Sink& operator<<(Sink& sink, const string& s) {
+Sink& operator<<(Sink& sink, const std::string& s) {
   writeString((const unsigned char*)s.data(), s.size(), sink);
   return sink;
 }
@@ -269,7 +269,7 @@ size_t readString(unsigned char* buf, size_t max, Source& source) {
   return len;
 }
 
-string readString(Source& source, size_t max) {
+std::string readString(Source& source, size_t max) {
   auto len = readNum<size_t>(source);
   if (len > max) {
     throw SerialisationError("string is too long");
@@ -280,7 +280,7 @@ string readString(Source& source, size_t max) {
   return res;
 }
 
-Source& operator>>(Source& in, string& s) {
+Source& operator>>(Source& in, std::string& s) {
   s = readString(in);
   return in;
 }
diff --git a/third_party/nix/src/libutil/serialise.hh b/third_party/nix/src/libutil/serialise.hh
index a5992b50ec..dc877487ee 100644
--- a/third_party/nix/src/libutil/serialise.hh
+++ b/third_party/nix/src/libutil/serialise.hh
@@ -135,9 +135,9 @@ struct StringSink : Sink {
 
 /* A source that reads data from a string. */
 struct StringSource : Source {
-  const string& s;
+  const std::string& s;
   size_t pos;
-  StringSource(const string& _s) : s(_s), pos(0) {}
+  StringSource(const std::string& _s) : s(_s), pos(0) {}
   size_t read(unsigned char* data, size_t len) override;
 };
 
@@ -231,7 +231,7 @@ inline Sink& operator<<(Sink& sink, uint64_t n) {
   return sink;
 }
 
-Sink& operator<<(Sink& sink, const string& s);
+Sink& operator<<(Sink& sink, const std::string& s);
 Sink& operator<<(Sink& sink, const Strings& s);
 Sink& operator<<(Sink& sink, const StringSet& s);
 
@@ -265,12 +265,12 @@ inline uint64_t readLongLong(Source& source) {
 
 void readPadding(size_t len, Source& source);
 size_t readString(unsigned char* buf, size_t max, Source& source);
-string readString(Source& source,
-                  size_t max = std::numeric_limits<size_t>::max());
+std::string readString(Source& source,
+                       size_t max = std::numeric_limits<size_t>::max());
 template <class T>
 T readStrings(Source& source);
 
-Source& operator>>(Source& in, string& s);
+Source& operator>>(Source& in, std::string& s);
 
 template <typename T>
 Source& operator>>(Source& in, T& n) {
diff --git a/third_party/nix/src/libutil/types.hh b/third_party/nix/src/libutil/types.hh
index ac1b802ce0..ad44719afe 100644
--- a/third_party/nix/src/libutil/types.hh
+++ b/third_party/nix/src/libutil/types.hh
@@ -22,10 +22,6 @@ namespace nix {
 
 /* Inherit some names from other namespaces for convenience. */
 using boost::format;
-using std::list;
-using std::set;
-using std::string;
-using std::vector;
 
 /* A variadic template that does nothing. Useful to call a function
    for all variadic arguments but ignoring the result. */
@@ -35,8 +31,8 @@ struct nop {
 };
 
 struct FormatOrString {
-  string s;
-  FormatOrString(const string& s) : s(s){};
+  std::string s;
+  FormatOrString(const std::string& s) : s(s){};
   FormatOrString(const format& f) : s(f.str()){};
   FormatOrString(const char* s) : s(s){};
 };
@@ -64,8 +60,8 @@ inline std::string fmt(const std::string& fs, Args... args) {
    a subclass. Catch Error instead. */
 class BaseError : public std::exception {
  protected:
-  string prefix_;  // used for location traces etc.
-  string err;
+  std::string prefix_;  // used for location traces etc.
+  std::string err;
 
  public:
   unsigned int status = 1;  // exit status
@@ -84,8 +80,8 @@ class BaseError : public std::exception {
   const char* what() const noexcept { return err.c_str(); }
 #endif
 
-  const string& msg() const { return err; }
-  const string& prefix() const { return prefix_; }
+  const std::string& msg() const { return err; }
+  const std::string& prefix() const { return prefix_; }
   BaseError& addPrefix(const FormatOrString& fs);
 };
 
@@ -108,13 +104,13 @@ MakeError(Error, BaseError)
   std::string addErrno(const std::string& s);
 };
 
-typedef list<string> Strings;
-typedef set<string> StringSet;
+typedef std::list<std::string> Strings;
+typedef std::set<std::string> StringSet;
 typedef std::map<std::string, std::string> StringMap;
 
 /* Paths are just strings. */
-typedef string Path;
-typedef list<Path> Paths;
-typedef set<Path> PathSet;
+typedef std::string Path;
+typedef std::list<Path> Paths;
+typedef std::set<Path> PathSet;
 
 }  // namespace nix
diff --git a/third_party/nix/src/libutil/util.cc b/third_party/nix/src/libutil/util.cc
index 53d037cf58..696a8ff236 100644
--- a/third_party/nix/src/libutil/util.cc
+++ b/third_party/nix/src/libutil/util.cc
@@ -42,9 +42,9 @@ std::string SysError::addErrno(const std::string& s) {
   return s + ": " + strerror(errNo);
 }
 
-string getEnv(const string& key, const string& def) {
+std::string getEnv(const std::string& key, const std::string& def) {
   char* value = getenv(key.c_str());
-  return value != nullptr ? string(value) : def;
+  return value != nullptr ? std::string(value) : def;
 }
 
 std::map<std::string, std::string> getEnv() {
@@ -101,15 +101,15 @@ return canonPath(path);
 Path canonPath(const Path& path, bool resolveSymlinks) {
   assert(!path.empty());
 
-  string s;
+  std::string s;
 
   if (path[0] != '/') {
     throw Error(format("not an absolute path: '%1%'") % path);
   }
 
-  string::const_iterator i = path.begin();
-  string::const_iterator end = path.end();
-  string temp;
+  std::string::const_iterator i = path.begin();
+  std::string::const_iterator end = path.end();
+  std::string temp;
 
   /* Count the number of times we follow a symlink and stop at some
      arbitrary (but high) limit to prevent infinite loops. */
@@ -153,7 +153,7 @@ Path canonPath(const Path& path, bool resolveSymlinks) {
           throw Error(format("infinite symlink recursion in path '%1%'") %
                       path);
         }
-        temp = absPath(readLink(s), dirOf(s)) + string(i, end);
+        temp = absPath(readLink(s), dirOf(s)) + std::string(i, end);
         i = temp.begin(); /* restart */
         end = temp.end();
         s = "";
@@ -166,13 +166,13 @@ Path canonPath(const Path& path, bool resolveSymlinks) {
 
 Path dirOf(const Path& path) {
   Path::size_type pos = path.rfind('/');
-  if (pos == string::npos) {
+  if (pos == std::string::npos) {
     return ".";
   }
   return pos == 0 ? "/" : Path(path, 0, pos);
 }
 
-string baseNameOf(const Path& path) {
+std::string baseNameOf(const Path& path) {
   if (path.empty()) {
     return "";
   }
@@ -183,17 +183,17 @@ string baseNameOf(const Path& path) {
   }
 
   Path::size_type pos = path.rfind('/', last);
-  if (pos == string::npos) {
+  if (pos == std::string::npos) {
     pos = 0;
   } else {
     pos += 1;
   }
 
-  return string(path, pos, last - pos + 1);
+  return std::string(path, pos, last - pos + 1);
 }
 
 bool isInDir(const Path& path, const Path& dir) {
-  return path[0] == '/' && string(path, 0, dir.size()) == dir &&
+  return path[0] == '/' && std::string(path, 0, dir.size()) == dir &&
          path.size() >= dir.size() + 2 && path[dir.size()] == '/';
 }
 
@@ -235,7 +235,7 @@ Path readLink(const Path& path) {
       throw SysError("reading symbolic link '%1%'", path);
 
     } else if (rlSize < bufSize) {
-      return string(buf.data(), rlSize);
+      return std::string(buf.data(), rlSize);
     }
   }
 }
@@ -252,7 +252,7 @@ DirEntries readDirectory(DIR* dir, const Path& path) {
   struct dirent* dirent;
   while (errno = 0, dirent = readdir(dir)) { /* sic */
     checkInterrupt();
-    string name = dirent->d_name;
+    std::string name = dirent->d_name;
     if (name == "." || name == "..") {
       continue;
     }
@@ -294,7 +294,7 @@ unsigned char getFileType(const Path& path) {
   return DT_UNKNOWN;
 }
 
-string readFile(int fd) {
+std::string readFile(int fd) {
   struct stat st;
   if (fstat(fd, &st) == -1) {
     throw SysError("statting file");
@@ -303,10 +303,10 @@ string readFile(int fd) {
   std::vector<unsigned char> buf(st.st_size);
   readFull(fd, buf.data(), st.st_size);
 
-  return string((char*)buf.data(), st.st_size);
+  return std::string((char*)buf.data(), st.st_size);
 }
 
-string readFile(const Path& path, bool drain) {
+std::string readFile(const Path& path, bool drain) {
   AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_CLOEXEC);
   if (!fd) {
     throw SysError(format("opening file '%1%'") % path);
@@ -322,7 +322,7 @@ void readFile(const Path& path, Sink& sink) {
   drainFD(fd.get(), sink);
 }
 
-void writeFile(const Path& path, const string& s, mode_t mode) {
+void writeFile(const Path& path, const std::string& s, mode_t mode) {
   AutoCloseFD fd =
       open(path.c_str(), O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, mode);
   if (!fd) {
@@ -350,8 +350,8 @@ void writeFile(const Path& path, Source& source, mode_t mode) {
   }
 }
 
-string readLine(int fd) {
-  string s;
+std::string readLine(int fd) {
+  std::string s;
   while (true) {
     checkInterrupt();
     char ch;
@@ -372,7 +372,7 @@ string readLine(int fd) {
   }
 }
 
-void writeLine(int fd, string s) {
+void writeLine(int fd, std::string s) {
   s += '\n';
   writeFull(fd, s);
 }
@@ -381,7 +381,7 @@ static void _deletePath(int parentfd, const Path& path,
                         unsigned long long& bytesFreed) {
   checkInterrupt();
 
-  string name(baseNameOf(path));
+  std::string name(baseNameOf(path));
 
   struct stat st;
   if (fstatat(parentfd, name.c_str(), &st, AT_SYMLINK_NOFOLLOW) == -1) {
@@ -539,8 +539,8 @@ Path getConfigDir() {
 
 std::vector<Path> getConfigDirs() {
   Path configHome = getConfigDir();
-  string configDirs = getEnv("XDG_CONFIG_DIRS");
-  auto result = tokenizeString<std::vector<string>>(configDirs, ":");
+  std::string configDirs = getEnv("XDG_CONFIG_DIRS");
+  auto result = tokenizeString<std::vector<std::string>>(configDirs, ":");
   result.insert(result.begin(), configHome);
   return result;
 }
@@ -643,11 +643,11 @@ void writeFull(int fd, const unsigned char* buf, size_t count,
   }
 }
 
-void writeFull(int fd, const string& s, bool allowInterrupts) {
+void writeFull(int fd, const std::string& s, bool allowInterrupts) {
   writeFull(fd, (const unsigned char*)s.data(), s.size(), allowInterrupts);
 }
 
-string drainFD(int fd, bool block) {
+std::string drainFD(int fd, bool block) {
   StringSink sink;
   drainFD(fd, sink, block);
   return std::move(*sink.s);
@@ -694,7 +694,7 @@ void drainFD(int fd, Sink& sink, bool block) {
 
 AutoDelete::AutoDelete() : del{false} {}
 
-AutoDelete::AutoDelete(string p, bool recursive) : path(std::move(p)) {
+AutoDelete::AutoDelete(std::string p, bool recursive) : path(std::move(p)) {
   del = true;
   this->recursive = recursive;
 }
@@ -812,7 +812,7 @@ int Pid::kill() {
      process group, send the signal to every process in the child
      process group (which hopefully includes *all* its children). */
   if (::kill(separatePG ? -pid : pid, killSignal) != 0) {
-      LOG(ERROR) << SysError("killing process %d", pid).msg();
+    LOG(ERROR) << SysError("killing process %d", pid).msg();
   }
 
   return wait();
@@ -950,8 +950,9 @@ std::vector<char*> stringsToCharPtrs(const Strings& ss) {
   return res;
 }
 
-string runProgram(const Path& program, bool searchPath, const Strings& args,
-                  const std::optional<std::string>& input) {
+std::string runProgram(const Path& program, bool searchPath,
+                       const Strings& args,
+                       const std::optional<std::string>& input) {
   RunOptions opts(program, args);
   opts.searchPath = searchPath;
   opts.input = input;
@@ -1114,7 +1115,7 @@ void runProgram2(const RunOptions& options) {
   }
 }
 
-void closeMostFDs(const set<int>& exceptions) {
+void closeMostFDs(const std::set<int>& exceptions) {
 #if __linux__
   try {
     for (auto& s : readDirectory("/proc/self/fd")) {
@@ -1168,28 +1169,30 @@ void _interrupted() {
 //////////////////////////////////////////////////////////////////////
 
 template <class C>
-C tokenizeString(const string& s, const string& separators) {
+C tokenizeString(const std::string& s, const std::string& separators) {
   C result;
-  string::size_type pos = s.find_first_not_of(separators, 0);
-  while (pos != string::npos) {
-    string::size_type end = s.find_first_of(separators, pos + 1);
-    if (end == string::npos) {
+  std::string::size_type pos = s.find_first_not_of(separators, 0);
+  while (pos != std::string::npos) {
+    std::string::size_type end = s.find_first_of(separators, pos + 1);
+    if (end == std::string::npos) {
       end = s.size();
     }
-    string token(s, pos, end - pos);
+    std::string token(s, pos, end - pos);
     result.insert(result.end(), token);
     pos = s.find_first_not_of(separators, end);
   }
   return result;
 }
 
-template Strings tokenizeString(const string& s, const string& separators);
-template StringSet tokenizeString(const string& s, const string& separators);
-template vector<string> tokenizeString(const string& s,
-                                       const string& separators);
+template Strings tokenizeString(const std::string& s,
+                                const std::string& separators);
+template StringSet tokenizeString(const std::string& s,
+                                  const std::string& separators);
+template std::vector<std::string> tokenizeString(const std::string& s,
+                                                 const std::string& separators);
 
-string concatStringsSep(const string& sep, const Strings& ss) {
-  string s;
+std::string concatStringsSep(const std::string& sep, const Strings& ss) {
+  std::string s;
   for (auto& i : ss) {
     if (!s.empty()) {
       s += sep;
@@ -1199,8 +1202,8 @@ string concatStringsSep(const string& sep, const Strings& ss) {
   return s;
 }
 
-string concatStringsSep(const string& sep, const StringSet& ss) {
-  string s;
+std::string concatStringsSep(const std::string& sep, const StringSet& ss) {
+  std::string s;
   for (auto& i : ss) {
     if (!s.empty()) {
       s += sep;
@@ -1210,21 +1213,21 @@ string concatStringsSep(const string& sep, const StringSet& ss) {
   return s;
 }
 
-string trim(const string& s, const string& whitespace) {
+std::string trim(const std::string& s, const std::string& whitespace) {
   auto i = s.find_first_not_of(whitespace);
-  if (i == string::npos) {
+  if (i == std::string::npos) {
     return "";
   }
   auto j = s.find_last_not_of(whitespace);
-  return string(s, i, j == string::npos ? j : j - i + 1);
+  return std::string(s, i, j == std::string::npos ? j : j - i + 1);
 }
 
-string replaceStrings(const std::string& s, const std::string& from,
-                      const std::string& to) {
+std::string replaceStrings(const std::string& s, const std::string& from,
+                           const std::string& to) {
   if (from.empty()) {
     return s;
   }
-  string res = s;
+  std::string res = s;
   size_t pos = 0;
   while ((pos = res.find(from, pos)) != std::string::npos) {
     res.replace(pos, from.size(), to);
@@ -1233,7 +1236,7 @@ string replaceStrings(const std::string& s, const std::string& from,
   return res;
 }
 
-string statusToString(int status) {
+std::string statusToString(int status) {
   if (!WIFEXITED(status) || WEXITSTATUS(status) != 0) {
     if (WIFEXITED(status)) {
       return (format("failed with exit code %1%") % WEXITSTATUS(status)).str();
@@ -1259,13 +1262,13 @@ bool statusOk(int status) {
   return WIFEXITED(status) && WEXITSTATUS(status) == 0;
 }
 
-bool hasPrefix(const string& s, const string& prefix) {
+bool hasPrefix(const std::string& s, const std::string& prefix) {
   return s.compare(0, prefix.size(), prefix) == 0;
 }
 
-bool hasSuffix(const string& s, const string& suffix) {
+bool hasSuffix(const std::string& s, const std::string& suffix) {
   return s.size() >= suffix.size() &&
-         string(s, s.size() - suffix.size()) == suffix;
+         std::string(s, s.size() - suffix.size()) == suffix;
 }
 
 std::string toLower(const std::string& s) {
@@ -1361,8 +1364,8 @@ std::string filterANSIEscapes(const std::string& s, bool filterAll,
 static char base64Chars[] =
     "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
 
-string base64Encode(const string& s) {
-  string res;
+std::string base64Encode(const std::string& s) {
+  std::string res;
   int data = 0;
   int nbits = 0;
 
@@ -1385,7 +1388,7 @@ string base64Encode(const string& s) {
   return res;
 }
 
-string base64Decode(const string& s) {
+std::string base64Decode(const std::string& s) {
   bool init = false;
   char decode[256];
   if (!init) {
@@ -1397,7 +1400,7 @@ string base64Decode(const string& s) {
     init = true;
   }
 
-  string res;
+  std::string res;
   unsigned int d = 0;
   unsigned int bits = 0;
 
diff --git a/third_party/nix/src/libutil/util.hh b/third_party/nix/src/libutil/util.hh
index 3c8d4bd70c..7d10df50bf 100644
--- a/third_party/nix/src/libutil/util.hh
+++ b/third_party/nix/src/libutil/util.hh
@@ -32,7 +32,7 @@ struct Source;
 extern const std::string nativeSystem;
 
 /* Return an environment variable. */
-string getEnv(const string& key, const string& def = "");
+std::string getEnv(const std::string& key, const std::string& def = "");
 
 /* Get the entire environment. */
 std::map<std::string, std::string> getEnv();
@@ -59,7 +59,7 @@ Path dirOf(const Path& path);
 
 /* Return the base name of the given canonical path, i.e., everything
    following the final `/'. */
-string baseNameOf(const Path& path);
+std::string baseNameOf(const Path& path);
 
 /* Check whether 'path' is a descendant of 'dir'. */
 bool isInDir(const Path& path, const Path& dir);
@@ -82,34 +82,34 @@ bool isLink(const Path& path);
 /* Read the contents of a directory.  The entries `.' and `..' are
    removed. */
 struct DirEntry {
-  string name;
+  std::string name;
   ino_t ino;
   unsigned char type;  // one of DT_*
-  DirEntry(const string& name, ino_t ino, unsigned char type)
+  DirEntry(const std::string& name, ino_t ino, unsigned char type)
       : name(name), ino(ino), type(type) {}
 };
 
-typedef vector<DirEntry> DirEntries;
+typedef std::vector<DirEntry> DirEntries;
 
 DirEntries readDirectory(const Path& path);
 
 unsigned char getFileType(const Path& path);
 
 /* Read the contents of a file into a string. */
-string readFile(int fd);
-string readFile(const Path& path, bool drain = false);
+std::string readFile(int fd);
+std::string readFile(const Path& path, bool drain = false);
 void readFile(const Path& path, Sink& sink);
 
 /* Write a string to a file. */
-void writeFile(const Path& path, const string& s, mode_t mode = 0666);
+void writeFile(const Path& path, const std::string& s, mode_t mode = 0666);
 
 void writeFile(const Path& path, Source& source, mode_t mode = 0666);
 
 /* Read a line from a file descriptor. */
-string readLine(int fd);
+std::string readLine(int fd);
 
 /* Write a line to a file descriptor. */
-void writeLine(int fd, string s);
+void writeLine(int fd, std::string s);
 
 /* Delete a path; i.e., in the case of a directory, it is deleted
    recursively. It's not an error if the path does not exist. The
@@ -155,12 +155,12 @@ void replaceSymlink(const Path& target, const Path& link);
 void readFull(int fd, unsigned char* buf, size_t count);
 void writeFull(int fd, const unsigned char* buf, size_t count,
                bool allowInterrupts = true);
-void writeFull(int fd, const string& s, bool allowInterrupts = true);
+void writeFull(int fd, const std::string& s, bool allowInterrupts = true);
 
-MakeError(EndOfFile, Error)
+MakeError(EndOfFile, Error);
 
-    /* Read a file descriptor until EOF occurs. */
-    string drainFD(int fd, bool block = true);
+/* Read a file descriptor until EOF occurs. */
+std::string drainFD(int fd, bool block = true);
 
 void drainFD(int fd, Sink& sink, bool block = true);
 
@@ -235,7 +235,7 @@ void killUser(uid_t uid);
 /* Fork a process that runs the given function, and return the child
    pid to the caller. */
 struct ProcessOptions {
-  string errorPrefix = "error: ";
+  std::string errorPrefix = "error: ";
   bool dieWithParent = true;
   bool runExitHandlers = false;
   bool allowVfork = true;
@@ -246,9 +246,9 @@ pid_t startProcess(std::function<void()> fun,
 
 /* Run a program and return its stdout in a string (i.e., like the
    shell backtick operator). */
-string runProgram(const Path& program, bool searchPath = false,
-                  const Strings& args = Strings(),
-                  const std::optional<std::string>& input = {});
+std::string runProgram(const Path& program, bool searchPath = false,
+                       const Strings& args = Strings(),
+                       const std::optional<std::string>& input = {});
 
 struct RunOptions {
   std::optional<uid_t> uid;
@@ -292,7 +292,7 @@ std::vector<char*> stringsToCharPtrs(const Strings& ss);
 
 /* Close all file descriptors except those listed in the given set.
    Good practice in child processes. */
-void closeMostFDs(const set<int>& exceptions);
+void closeMostFDs(const std::set<int>& exceptions);
 
 /* Set the close-on-exec flag for the given file descriptor. */
 void closeOnExec(int fd);
@@ -311,36 +311,38 @@ void inline checkInterrupt() {
   if (_isInterrupted || (interruptCheck && interruptCheck())) _interrupted();
 }
 
-MakeError(Interrupted, BaseError)
+MakeError(Interrupted, BaseError);
 
-    MakeError(FormatError, Error)
+MakeError(FormatError, Error);
 
-    /* String tokenizer. */
-    template <class C>
-    C tokenizeString(const string& s, const string& separators = " \t\n\r");
+/* String tokenizer. */
+template <class C>
+C tokenizeString(const std::string& s,
+                 const std::string& separators = " \t\n\r");
 
 /* Concatenate the given strings with a separator between the
    elements. */
-string concatStringsSep(const string& sep, const Strings& ss);
-string concatStringsSep(const string& sep, const StringSet& ss);
+std::string concatStringsSep(const std::string& sep, const Strings& ss);
+std::string concatStringsSep(const std::string& sep, const StringSet& ss);
 
 /* Remove whitespace from the start and end of a string. */
-string trim(const string& s, const string& whitespace = " \n\r\t");
+std::string trim(const std::string& s,
+                 const std::string& whitespace = " \n\r\t");
 
 /* Replace all occurrences of a string inside another string. */
-string replaceStrings(const std::string& s, const std::string& from,
-                      const std::string& to);
+std::string replaceStrings(const std::string& s, const std::string& from,
+                           const std::string& to);
 
 /* Convert the exit status of a child as returned by wait() into an
    error string. */
-string statusToString(int status);
+std::string statusToString(int status);
 
 bool statusOk(int status);
 
 /* Parse a string into an integer. */
 template <class N>
-bool string2Int(const string& s, N& n) {
-  if (string(s, 0, 1) == "-" && !std::numeric_limits<N>::is_signed)
+bool string2Int(const std::string& s, N& n) {
+  if (std::string(s, 0, 1) == "-" && !std::numeric_limits<N>::is_signed)
     return false;
   std::istringstream str(s);
   str >> n;
@@ -349,17 +351,17 @@ bool string2Int(const string& s, N& n) {
 
 /* Parse a string into a float. */
 template <class N>
-bool string2Float(const string& s, N& n) {
+bool string2Float(const std::string& s, N& n) {
   std::istringstream str(s);
   str >> n;
   return str && str.get() == EOF;
 }
 
 /* Return true iff `s' starts with `prefix'. */
-bool hasPrefix(const string& s, const string& prefix);
+bool hasPrefix(const std::string& s, const std::string& prefix);
 
 /* Return true iff `s' ends in `suffix'. */
-bool hasSuffix(const string& s, const string& suffix);
+bool hasSuffix(const std::string& s, const std::string& suffix);
 
 /* Convert a string to lower case. */
 std::string toLower(const std::string& s);
@@ -389,13 +391,14 @@ std::string filterANSIEscapes(
     unsigned int width = std::numeric_limits<unsigned int>::max());
 
 /* Base64 encoding/decoding. */
-string base64Encode(const string& s);
-string base64Decode(const string& s);
+std::string base64Encode(const std::string& s);
+std::string base64Decode(const std::string& s);
 
 /* Get a value for the specified key from an associate container, or a
    default value if the key doesn't exist. */
 template <class T>
-string get(const T& map, const string& key, const string& def = "") {
+std::string get(const T& map, const std::string& key,
+                const std::string& def = "") {
   auto i = map.find(key);
   return i == map.end() ? def : i->second;
 }
diff --git a/third_party/nix/src/libutil/xml-writer.cc b/third_party/nix/src/libutil/xml-writer.cc
index 11cd632399..d34e9a2f0d 100644
--- a/third_party/nix/src/libutil/xml-writer.cc
+++ b/third_party/nix/src/libutil/xml-writer.cc
@@ -26,10 +26,10 @@ void XMLWriter::indent_(size_t depth) {
   if (!indent) {
     return;
   }
-  output << string(depth * 2, ' ');
+  output << std::string(depth * 2, ' ');
 }
 
-void XMLWriter::openElement(const string& name, const XMLAttrs& attrs) {
+void XMLWriter::openElement(const std::string& name, const XMLAttrs& attrs) {
   assert(!closed);
   indent_(pendingElems.size());
   output << "<" << name;
@@ -54,7 +54,8 @@ void XMLWriter::closeElement() {
   }
 }
 
-void XMLWriter::writeEmptyElement(const string& name, const XMLAttrs& attrs) {
+void XMLWriter::writeEmptyElement(const std::string& name,
+                                  const XMLAttrs& attrs) {
   assert(!closed);
   indent_(pendingElems.size());
   output << "<" << name;
diff --git a/third_party/nix/src/libutil/xml-writer.hh b/third_party/nix/src/libutil/xml-writer.hh
index 3a2d9a66d8..76f3c7e3a2 100644
--- a/third_party/nix/src/libutil/xml-writer.hh
+++ b/third_party/nix/src/libutil/xml-writer.hh
@@ -11,7 +11,7 @@ using std::list;
 using std::map;
 using std::string;
 
-typedef map<string, string> XMLAttrs;
+typedef map<std::string, std::string> XMLAttrs;
 
 class XMLWriter {
  private:
@@ -20,7 +20,7 @@ class XMLWriter {
   bool indent;
   bool closed;
 
-  list<string> pendingElems;
+  std::list<std::string> pendingElems;
 
  public:
   XMLWriter(bool indent, std::ostream& output);
@@ -28,10 +28,10 @@ class XMLWriter {
 
   void close();
 
-  void openElement(const string& name, const XMLAttrs& attrs = XMLAttrs());
+  void openElement(const std::string& name, const XMLAttrs& attrs = XMLAttrs());
   void closeElement();
 
-  void writeEmptyElement(const string& name,
+  void writeEmptyElement(const std::string& name,
                          const XMLAttrs& attrs = XMLAttrs());
 
  private:
@@ -45,7 +45,7 @@ class XMLOpenElement {
   XMLWriter& writer;
 
  public:
-  XMLOpenElement(XMLWriter& writer, const string& name,
+  XMLOpenElement(XMLWriter& writer, const std::string& name,
                  const XMLAttrs& attrs = XMLAttrs())
       : writer(writer) {
     writer.openElement(name, attrs);