about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/nar-info.cc
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-05-18T15·39+0200
committerclbot <clbot@tvl.fyi>2022-05-19T14·08+0000
commitd127f9bd0e7b9b2e0df2de8a2227f77c0907468d (patch)
tree68455040d88b8e0c2817601db88ede450873ff8e /third_party/nix/src/libstore/nar-info.cc
parentc85291c602ac666421627d6934ebc6d5be1b93e1 (diff)
chore(3p/nix): unvendor tvix 0.1 r/4098
Nothing is using this now, and we'll likely never pick this up again,
but we learned a lot in the process.

Every now and then this breaks in some bizarre way on channel bumps
and it's just a waste of time to maintain that.

Change-Id: Idcf2f5acd4ca7070ce18d7149cbfc0d967dc0a44
Reviewed-on: https://cl.tvl.fyi/c/depot/+/5632
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Reviewed-by: lukegb <lukegb@tvl.fyi>
Autosubmit: tazjin <tazjin@tvl.su>
Diffstat (limited to 'third_party/nix/src/libstore/nar-info.cc')
-rw-r--r--third_party/nix/src/libstore/nar-info.cc142
1 files changed, 0 insertions, 142 deletions
diff --git a/third_party/nix/src/libstore/nar-info.cc b/third_party/nix/src/libstore/nar-info.cc
deleted file mode 100644
index d42167dbfa69..000000000000
--- a/third_party/nix/src/libstore/nar-info.cc
+++ /dev/null
@@ -1,142 +0,0 @@
-#include "libstore/nar-info.hh"
-
-#include <absl/strings/numbers.h>
-#include <absl/strings/str_split.h>
-
-#include "libstore/globals.hh"
-
-namespace nix {
-
-NarInfo::NarInfo(const Store& store, const std::string& s,
-                 const std::string& whence) {
-  auto corrupt = [&]() {
-    throw Error(format("NAR info file '%1%' is corrupt") % whence);
-  };
-
-  auto parseHashField = [&](const std::string& s) {
-    auto hash_ = Hash::deserialize(s);
-    if (hash_.ok()) {
-      return *hash_;
-    } else {
-      // TODO(#statusor): return an actual error
-      corrupt();
-      return Hash();
-    }
-  };
-
-  size_t pos = 0;
-  while (pos < s.size()) {
-    size_t colon = s.find(':', pos);
-    if (colon == std::string::npos) {
-      corrupt();
-    }
-
-    std::string name(s, pos, colon - pos);
-
-    size_t eol = s.find('\n', colon + 2);
-    if (eol == std::string::npos) {
-      corrupt();
-    }
-
-    std::string value(s, colon + 2, eol - colon - 2);
-
-    if (name == "StorePath") {
-      if (!store.isStorePath(value)) {
-        corrupt();
-      }
-      path = value;
-    } else if (name == "URL") {
-      url = value;
-    } else if (name == "Compression") {
-      compression = value;
-    } else if (name == "FileHash") {
-      fileHash = parseHashField(value);
-    } else if (name == "FileSize") {
-      if (!absl::SimpleAtoi(value, &fileSize)) {
-        corrupt();
-      }
-    } else if (name == "NarHash") {
-      narHash = parseHashField(value);
-    } else if (name == "NarSize") {
-      if (!absl::SimpleAtoi(value, &narSize)) {
-        corrupt();
-      }
-    } else if (name == "References") {
-      std::vector<std::string> refs =
-          absl::StrSplit(value, absl::ByChar(' '), absl::SkipEmpty());
-      if (!references.empty()) {
-        corrupt();
-      }
-      for (auto& r : refs) {
-        auto r2 = store.storeDir + "/" + r;
-        if (!store.isStorePath(r2)) {
-          corrupt();
-        }
-        references.insert(r2);
-      }
-    } else if (name == "Deriver") {
-      if (value != "unknown-deriver") {
-        auto p = store.storeDir + "/" + value;
-        if (!store.isStorePath(p)) {
-          corrupt();
-        }
-        deriver = p;
-      }
-    } else if (name == "System") {
-      system = value;
-    } else if (name == "Sig") {
-      sigs.insert(value);
-    } else if (name == "CA") {
-      if (!ca.empty()) {
-        corrupt();
-      }
-      ca = value;
-    }
-
-    pos = eol + 1;
-  }
-
-  if (compression.empty()) {
-    compression = "bzip2";
-  }
-
-  if (path.empty() || url.empty() || narSize == 0 || !narHash) {
-    corrupt();
-  }
-}
-
-std::string NarInfo::to_string() const {
-  std::string res;
-  res += "StorePath: " + path + "\n";
-  res += "URL: " + url + "\n";
-  assert(!compression.empty());
-  res += "Compression: " + compression + "\n";
-  assert(fileHash.type == htSHA256);
-  res += "FileHash: " + fileHash.to_string(Base32) + "\n";
-  res += "FileSize: " + std::to_string(fileSize) + "\n";
-  assert(narHash.type == htSHA256);
-  res += "NarHash: " + narHash.to_string(Base32) + "\n";
-  res += "NarSize: " + std::to_string(narSize) + "\n";
-
-  res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";
-
-  if (!deriver.empty()) {
-    res += "Deriver: " + baseNameOf(deriver) + "\n";
-  }
-
-  if (!system.empty()) {
-    res += "System: " + system + "\n";
-  }
-
-  for (const auto& sig : sigs) {
-    res += "Sig: " + sig + "\n";
-  }
-
-  if (!ca.empty()) {
-    res += "CA: " + ca + "\n";
-  }
-
-  return res;
-}
-
-}  // namespace nix