diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2022-04-19 12:09:12 +0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2022-04-19 13:41:32 +0200 |
commit | 2016b7142ad1282981ad1505085fff0ac9c7d66c (patch) | |
tree | de2e3fd53e449af6db757ee461baa751366636d6 /src/nix/app.cc | |
parent | b529a4181444e0c52234b3900b89dc7994d5268f (diff) |
Fix compilation, style fixes
Diffstat (limited to 'src/nix/app.cc')
-rw-r--r-- | src/nix/app.cc | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/src/nix/app.cc b/src/nix/app.cc index bd6988066..6b6b31a12 100644 --- a/src/nix/app.cc +++ b/src/nix/app.cc @@ -62,22 +62,17 @@ std::string resolveString(Store & store, const std::string & toResolve, const Bu UnresolvedApp Installable::toApp(EvalState & state) { auto cursor = getCursor(state); + auto attrPath = cursor->getAttrPath(); auto type = cursor->getAttr("type")->getString(); - std::string expected; - if (hasPrefix(attrPath,"apps.")) { - expected = "app"; - } else { - expected = "derivation"; - } - if (type != expected) { - throw Error("Attribute '%s' should have type '%s'.", attrPath, expected); - } + std::string expected = !attrPath.empty() && attrPath[0] == "apps" ? "app" : "derivation"; + if (type != expected) + throw Error("attribute '%s' should have type '%s'", cursor->getAttrPathStr(), expected); + if (type == "app") { auto [program, context] = cursor->getAttr("program")->getStringWithContext(); - std::vector<StorePathWithOutputs> context2; for (auto & [path, name] : context) context2.push_back({path, {name}}); |