about summary refs log tree commit diff
path: root/third_party/nix/src/libstore/parsed-derivations.cc
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@google.com>2020-05-17T15·31+0100
committerVincent Ambo <tazjin@google.com>2020-05-17T15·31+0100
commit0f2cf531f705d370321843e5ba9135b2ebdb5d19 (patch)
tree256feb13963a849ed96e89228fa05454c2a22363 /third_party/nix/src/libstore/parsed-derivations.cc
parent65a1aae98ce5a237c9643e639e550c8b0c0be7f1 (diff)
style(3p/nix): Reformat project in Google C++ style r/740
Reformatted with:

    fd . -e hh -e cc | xargs clang-format -i
Diffstat (limited to 'third_party/nix/src/libstore/parsed-derivations.cc')
-rw-r--r--third_party/nix/src/libstore/parsed-derivations.cc180
1 files changed, 90 insertions, 90 deletions
diff --git a/third_party/nix/src/libstore/parsed-derivations.cc b/third_party/nix/src/libstore/parsed-derivations.cc
index 87be8a24ea..6a8c235a0c 100644
--- a/third_party/nix/src/libstore/parsed-derivations.cc
+++ b/third_party/nix/src/libstore/parsed-derivations.cc
@@ -2,115 +2,115 @@
 
 namespace nix {
 
-ParsedDerivation::ParsedDerivation(const Path & drvPath, BasicDerivation & drv)
-    : drvPath(drvPath), drv(drv)
-{
-    /* Parse the __json attribute, if any. */
-    auto jsonAttr = drv.env.find("__json");
-    if (jsonAttr != drv.env.end()) {
-        try {
-            structuredAttrs = nlohmann::json::parse(jsonAttr->second);
-        } catch (std::exception & e) {
-            throw Error("cannot process __json attribute of '%s': %s", drvPath, e.what());
-        }
+ParsedDerivation::ParsedDerivation(const Path& drvPath, BasicDerivation& drv)
+    : drvPath(drvPath), drv(drv) {
+  /* Parse the __json attribute, if any. */
+  auto jsonAttr = drv.env.find("__json");
+  if (jsonAttr != drv.env.end()) {
+    try {
+      structuredAttrs = nlohmann::json::parse(jsonAttr->second);
+    } catch (std::exception& e) {
+      throw Error("cannot process __json attribute of '%s': %s", drvPath,
+                  e.what());
     }
+  }
 }
 
-std::optional<std::string> ParsedDerivation::getStringAttr(const std::string & name) const
-{
-    if (structuredAttrs) {
-        auto i = structuredAttrs->find(name);
-        if (i == structuredAttrs->end())
-            return {};
-        else {
-            if (!i->is_string())
-                throw Error("attribute '%s' of derivation '%s' must be a string", name, drvPath);
-            return i->get<std::string>();
-        }
-    } else {
-        auto i = drv.env.find(name);
-        if (i == drv.env.end())
-            return {};
-        else
-            return i->second;
+std::optional<std::string> ParsedDerivation::getStringAttr(
+    const std::string& name) const {
+  if (structuredAttrs) {
+    auto i = structuredAttrs->find(name);
+    if (i == structuredAttrs->end())
+      return {};
+    else {
+      if (!i->is_string())
+        throw Error("attribute '%s' of derivation '%s' must be a string", name,
+                    drvPath);
+      return i->get<std::string>();
     }
+  } else {
+    auto i = drv.env.find(name);
+    if (i == drv.env.end())
+      return {};
+    else
+      return i->second;
+  }
 }
 
-bool ParsedDerivation::getBoolAttr(const std::string & name, bool def) const
-{
-    if (structuredAttrs) {
-        auto i = structuredAttrs->find(name);
-        if (i == structuredAttrs->end())
-            return def;
-        else {
-            if (!i->is_boolean())
-                throw Error("attribute '%s' of derivation '%s' must be a Boolean", name, drvPath);
-            return i->get<bool>();
-        }
-    } else {
-        auto i = drv.env.find(name);
-        if (i == drv.env.end())
-            return def;
-        else
-            return i->second == "1";
+bool ParsedDerivation::getBoolAttr(const std::string& name, bool def) const {
+  if (structuredAttrs) {
+    auto i = structuredAttrs->find(name);
+    if (i == structuredAttrs->end())
+      return def;
+    else {
+      if (!i->is_boolean())
+        throw Error("attribute '%s' of derivation '%s' must be a Boolean", name,
+                    drvPath);
+      return i->get<bool>();
     }
+  } else {
+    auto i = drv.env.find(name);
+    if (i == drv.env.end())
+      return def;
+    else
+      return i->second == "1";
+  }
 }
 
-std::optional<Strings> ParsedDerivation::getStringsAttr(const std::string & name) const
-{
-    if (structuredAttrs) {
-        auto i = structuredAttrs->find(name);
-        if (i == structuredAttrs->end())
-            return {};
-        else {
-            if (!i->is_array())
-                throw Error("attribute '%s' of derivation '%s' must be a list of strings", name, drvPath);
-            Strings res;
-            for (auto j = i->begin(); j != i->end(); ++j) {
-                if (!j->is_string())
-                    throw Error("attribute '%s' of derivation '%s' must be a list of strings", name, drvPath);
-                res.push_back(j->get<std::string>());
-            }
-            return res;
-        }
-    } else {
-        auto i = drv.env.find(name);
-        if (i == drv.env.end())
-            return {};
-        else
-            return tokenizeString<Strings>(i->second);
+std::optional<Strings> ParsedDerivation::getStringsAttr(
+    const std::string& name) const {
+  if (structuredAttrs) {
+    auto i = structuredAttrs->find(name);
+    if (i == structuredAttrs->end())
+      return {};
+    else {
+      if (!i->is_array())
+        throw Error(
+            "attribute '%s' of derivation '%s' must be a list of strings", name,
+            drvPath);
+      Strings res;
+      for (auto j = i->begin(); j != i->end(); ++j) {
+        if (!j->is_string())
+          throw Error(
+              "attribute '%s' of derivation '%s' must be a list of strings",
+              name, drvPath);
+        res.push_back(j->get<std::string>());
+      }
+      return res;
     }
+  } else {
+    auto i = drv.env.find(name);
+    if (i == drv.env.end())
+      return {};
+    else
+      return tokenizeString<Strings>(i->second);
+  }
 }
 
-StringSet ParsedDerivation::getRequiredSystemFeatures() const
-{
-    StringSet res;
-    for (auto & i : getStringsAttr("requiredSystemFeatures").value_or(Strings()))
-        res.insert(i);
-    return res;
+StringSet ParsedDerivation::getRequiredSystemFeatures() const {
+  StringSet res;
+  for (auto& i : getStringsAttr("requiredSystemFeatures").value_or(Strings()))
+    res.insert(i);
+  return res;
 }
 
-bool ParsedDerivation::canBuildLocally() const
-{
-    if (drv.platform != settings.thisSystem.get()
-        && !settings.extraPlatforms.get().count(drv.platform)
-        && !drv.isBuiltin())
-        return false;
+bool ParsedDerivation::canBuildLocally() const {
+  if (drv.platform != settings.thisSystem.get() &&
+      !settings.extraPlatforms.get().count(drv.platform) && !drv.isBuiltin())
+    return false;
 
-    for (auto & feature : getRequiredSystemFeatures())
-        if (!settings.systemFeatures.get().count(feature)) return false;
+  for (auto& feature : getRequiredSystemFeatures())
+    if (!settings.systemFeatures.get().count(feature)) return false;
 
-    return true;
+  return true;
 }
 
-bool ParsedDerivation::willBuildLocally() const
-{
-    return getBoolAttr("preferLocalBuild") && canBuildLocally();
+bool ParsedDerivation::willBuildLocally() const {
+  return getBoolAttr("preferLocalBuild") && canBuildLocally();
 }
 
-bool ParsedDerivation::substitutesAllowed() const
-{
-    return getBoolAttr("allowSubstitutes", true);
+bool ParsedDerivation::substitutesAllowed() const {
+  return getBoolAttr("allowSubstitutes", true);
 }
 
-}
+}  // namespace nix