about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/local-fs-store.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/local-fs-store.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/local-fs-store.cc')
-rw-r--r--third_party/nix/src/libstore/local-fs-store.cc123
1 files changed, 0 insertions, 123 deletions
diff --git a/third_party/nix/src/libstore/local-fs-store.cc b/third_party/nix/src/libstore/local-fs-store.cc
deleted file mode 100644
index f2235bad7677..000000000000
--- a/third_party/nix/src/libstore/local-fs-store.cc
+++ /dev/null
@@ -1,123 +0,0 @@
-#include "libstore/derivations.hh"
-#include "libstore/fs-accessor.hh"
-#include "libstore/globals.hh"
-#include "libstore/store-api.hh"
-#include "libutil/archive.hh"
-#include "libutil/compression.hh"
-
-namespace nix {
-
-LocalFSStore::LocalFSStore(const Params& params) : Store(params) {}
-
-struct LocalStoreAccessor : public FSAccessor {
-  ref<LocalFSStore> store;
-
-  explicit LocalStoreAccessor(const ref<LocalFSStore>& store) : store(store) {}
-
-  Path toRealPath(const Path& path) {
-    Path storePath = store->toStorePath(path);
-    if (!store->isValidPath(storePath)) {
-      throw InvalidPath(format("path '%1%' is not a valid store path") %
-                        storePath);
-    }
-    return store->getRealStoreDir() + std::string(path, store->storeDir.size());
-  }
-
-  FSAccessor::Stat stat(const Path& path) override {
-    auto realPath = toRealPath(path);
-
-    struct stat st;
-    if (lstat(realPath.c_str(), &st) != 0) {
-      if (errno == ENOENT || errno == ENOTDIR) {
-        return {Type::tMissing, 0, false};
-      }
-      throw SysError(format("getting status of '%1%'") % path);
-    }
-
-    if (!S_ISREG(st.st_mode) && !S_ISDIR(st.st_mode) && !S_ISLNK(st.st_mode)) {
-      throw Error(format("file '%1%' has unsupported type") % path);
-    }
-
-    return {S_ISREG(st.st_mode)   ? Type::tRegular
-            : S_ISLNK(st.st_mode) ? Type::tSymlink
-                                  : Type::tDirectory,
-            S_ISREG(st.st_mode) ? static_cast<uint64_t>(st.st_size) : 0,
-            S_ISREG(st.st_mode) && ((st.st_mode & S_IXUSR) != 0u)};
-  }
-
-  StringSet readDirectory(const Path& path) override {
-    auto realPath = toRealPath(path);
-
-    auto entries = nix::readDirectory(realPath);
-
-    StringSet res;
-    for (auto& entry : entries) {
-      res.insert(entry.name);
-    }
-
-    return res;
-  }
-
-  std::string readFile(const Path& path) override {
-    return nix::readFile(toRealPath(path));
-  }
-
-  std::string readLink(const Path& path) override {
-    return nix::readLink(toRealPath(path));
-  }
-};
-
-ref<FSAccessor> LocalFSStore::getFSAccessor() {
-  return make_ref<LocalStoreAccessor>(ref<LocalFSStore>(
-      std::dynamic_pointer_cast<LocalFSStore>(shared_from_this())));
-}
-
-void LocalFSStore::narFromPath(const Path& path, Sink& sink) {
-  if (!isValidPath(path)) {
-    throw Error(format("path '%s' is not valid") % path);
-  }
-  dumpPath(getRealStoreDir() + std::string(path, storeDir.size()), sink);
-}
-
-const std::string LocalFSStore::drvsLogDir = "drvs";
-
-std::shared_ptr<std::string> LocalFSStore::getBuildLog(const Path& path_) {
-  auto path(path_);
-
-  assertStorePath(path);
-
-  if (!isDerivation(path)) {
-    try {
-      path = queryPathInfo(path)->deriver;
-    } catch (InvalidPath&) {
-      return nullptr;
-    }
-    if (path.empty()) {
-      return nullptr;
-    }
-  }
-
-  std::string baseName = baseNameOf(path);
-
-  for (int j = 0; j < 2; j++) {
-    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)) {
-      return std::make_shared<std::string>(readFile(logPath));
-    }
-    if (pathExists(logBz2Path)) {
-      try {
-        return decompress("bzip2", readFile(logBz2Path));
-      } catch (Error&) {
-      }
-    }
-  }
-
-  return nullptr;
-}
-
-}  // namespace nix