resolve redundant priority passing, wrap NixInt in eval-cache variant
This commit is contained in:
parent
c81d24f1c7
commit
27d0f6747d
|
@ -609,7 +609,7 @@ InstallableFlake::InstallableFlake(
|
||||||
throw UsageError("'--arg' and '--argstr' are incompatible with flakes");
|
throw UsageError("'--arg' and '--argstr' are incompatible with flakes");
|
||||||
}
|
}
|
||||||
|
|
||||||
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo, std::optional<NixInt>> InstallableFlake::toDerivation()
|
std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo> InstallableFlake::toDerivation()
|
||||||
{
|
{
|
||||||
auto attr = getCursor(*state);
|
auto attr = getCursor(*state);
|
||||||
|
|
||||||
|
@ -650,7 +650,7 @@ std::tuple<std::string, FlakeRef, InstallableValue::DerivationInfo, std::optiona
|
||||||
.priority = priority,
|
.priority = priority,
|
||||||
};
|
};
|
||||||
|
|
||||||
return {attrPath, getLockedFlake()->flake.lockedRef, std::move(drvInfo), priority};
|
return {attrPath, getLockedFlake()->flake.lockedRef, std::move(drvInfo)};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations()
|
std::vector<InstallableValue::DerivationInfo> InstallableFlake::toDerivations()
|
||||||
|
|
|
@ -177,7 +177,7 @@ struct InstallableFlake : InstallableValue
|
||||||
|
|
||||||
Value * getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake);
|
Value * getFlakeOutputs(EvalState & state, const flake::LockedFlake & lockedFlake);
|
||||||
|
|
||||||
std::tuple<std::string, FlakeRef, DerivationInfo, std::optional<NixInt>> toDerivation();
|
std::tuple<std::string, FlakeRef, DerivationInfo> toDerivation();
|
||||||
|
|
||||||
std::vector<DerivationInfo> toDerivations() override;
|
std::vector<DerivationInfo> toDerivations() override;
|
||||||
|
|
||||||
|
|
|
@ -306,7 +306,7 @@ struct AttrDb
|
||||||
case AttrType::Bool:
|
case AttrType::Bool:
|
||||||
return {{rowId, queryAttribute.getInt(2) != 0}};
|
return {{rowId, queryAttribute.getInt(2) != 0}};
|
||||||
case AttrType::Int:
|
case AttrType::Int:
|
||||||
return {{rowId, queryAttribute.getInt(2)}};
|
return {{rowId, (int_t) queryAttribute.getInt(2)}};
|
||||||
case AttrType::ListOfStrings:
|
case AttrType::ListOfStrings:
|
||||||
return {{rowId, tokenizeString<std::vector<std::string>>(queryAttribute.getStr(2), "\t")}};
|
return {{rowId, tokenizeString<std::vector<std::string>>(queryAttribute.getStr(2), "\t")}};
|
||||||
case AttrType::Missing:
|
case AttrType::Missing:
|
||||||
|
@ -649,9 +649,9 @@ NixInt AttrCursor::getInt()
|
||||||
if (!cachedValue)
|
if (!cachedValue)
|
||||||
cachedValue = root->db->getAttr(getKey());
|
cachedValue = root->db->getAttr(getKey());
|
||||||
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
if (cachedValue && !std::get_if<placeholder_t>(&cachedValue->second)) {
|
||||||
if (auto i = std::get_if<NixInt>(&cachedValue->second)) {
|
if (auto i = std::get_if<int_t>(&cachedValue->second)) {
|
||||||
debug("using cached Integer attribute '%s'", getAttrPathStr());
|
debug("using cached Integer attribute '%s'", getAttrPathStr());
|
||||||
return *i;
|
return (*i).x;
|
||||||
} else
|
} else
|
||||||
throw TypeError("'%s' is not an Integer", getAttrPathStr());
|
throw TypeError("'%s' is not an Integer", getAttrPathStr());
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,6 +52,7 @@ struct placeholder_t {};
|
||||||
struct missing_t {};
|
struct missing_t {};
|
||||||
struct misc_t {};
|
struct misc_t {};
|
||||||
struct failed_t {};
|
struct failed_t {};
|
||||||
|
struct int_t { NixInt x; int_t(NixInt x) : x(x) {}; };
|
||||||
typedef uint64_t AttrId;
|
typedef uint64_t AttrId;
|
||||||
typedef std::pair<AttrId, Symbol> AttrKey;
|
typedef std::pair<AttrId, Symbol> AttrKey;
|
||||||
typedef std::pair<std::string, NixStringContext> string_t;
|
typedef std::pair<std::string, NixStringContext> string_t;
|
||||||
|
@ -64,7 +65,7 @@ typedef std::variant<
|
||||||
misc_t,
|
misc_t,
|
||||||
failed_t,
|
failed_t,
|
||||||
bool,
|
bool,
|
||||||
NixInt,
|
int_t,
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
> AttrValue;
|
> AttrValue;
|
||||||
|
|
||||||
|
|
|
@ -300,7 +300,7 @@ struct CmdProfileInstall : InstallablesCommand, MixDefaultProfile
|
||||||
|
|
||||||
if (auto installable2 = std::dynamic_pointer_cast<InstallableFlake>(installable)) {
|
if (auto installable2 = std::dynamic_pointer_cast<InstallableFlake>(installable)) {
|
||||||
// FIXME: make build() return this?
|
// FIXME: make build() return this?
|
||||||
auto [attrPath, resolvedRef, drv, priority] = installable2->toDerivation();
|
auto [attrPath, resolvedRef, drv] = installable2->toDerivation();
|
||||||
element.source = ProfileElementSource {
|
element.source = ProfileElementSource {
|
||||||
installable2->flakeRef,
|
installable2->flakeRef,
|
||||||
resolvedRef,
|
resolvedRef,
|
||||||
|
@ -475,7 +475,7 @@ struct CmdProfileUpgrade : virtual SourceExprCommand, MixDefaultProfile, MixProf
|
||||||
Strings{},
|
Strings{},
|
||||||
lockFlags);
|
lockFlags);
|
||||||
|
|
||||||
auto [attrPath, resolvedRef, drv, priority] = installable->toDerivation();
|
auto [attrPath, resolvedRef, drv] = installable->toDerivation();
|
||||||
|
|
||||||
if (element.source->resolvedRef == resolvedRef) continue;
|
if (element.source->resolvedRef == resolvedRef) continue;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue