mirror of
https://github.com/NixOS/nix
synced 2025-07-06 21:41:48 +02:00
Merge remote-tracking branch 'origin/master' into overlayfs-store
This commit is contained in:
commit
c0e6466a1e
29 changed files with 191 additions and 97 deletions
|
@ -12,7 +12,7 @@ struct ExperimentalFeatureDetails
|
|||
std::string_view description;
|
||||
};
|
||||
|
||||
constexpr std::array<ExperimentalFeatureDetails, 16> xpFeatureDetails = {{
|
||||
constexpr std::array<ExperimentalFeatureDetails, 15> xpFeatureDetails = {{
|
||||
{
|
||||
.tag = Xp::CaDerivations,
|
||||
.name = "ca-derivations",
|
||||
|
@ -182,15 +182,6 @@ constexpr std::array<ExperimentalFeatureDetails, 16> xpFeatureDetails = {{
|
|||
the [`use-cgroups`](#conf-use-cgroups) setting for details.
|
||||
)",
|
||||
},
|
||||
{
|
||||
.tag = Xp::DiscardReferences,
|
||||
.name = "discard-references",
|
||||
.description = R"(
|
||||
Allow the use of the [`unsafeDiscardReferences`](@docroot@/language/advanced-attributes.html#adv-attr-unsafeDiscardReferences) attribute in derivations
|
||||
that use [structured attributes](@docroot@/language/advanced-attributes.html#adv-attr-structuredAttrs). This disables scanning of outputs for
|
||||
runtime dependencies.
|
||||
)",
|
||||
},
|
||||
{
|
||||
.tag = Xp::DaemonTrustOverride,
|
||||
.name = "daemon-trust-override",
|
||||
|
|
|
@ -27,7 +27,6 @@ enum struct ExperimentalFeature
|
|||
ReplFlake,
|
||||
AutoAllocateUids,
|
||||
Cgroups,
|
||||
DiscardReferences,
|
||||
DaemonTrustOverride,
|
||||
DynamicDerivations,
|
||||
ParseTomlTimestamps,
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "json-utils.hh"
|
||||
#include "error.hh"
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
@ -16,4 +17,27 @@ nlohmann::json * get(nlohmann::json & map, const std::string & key)
|
|||
return &*i;
|
||||
}
|
||||
|
||||
const nlohmann::json & valueAt(
|
||||
const nlohmann::json & map,
|
||||
const std::string & key)
|
||||
{
|
||||
if (!map.contains(key))
|
||||
throw Error("Expected JSON object to contain key '%s' but it doesn't", key);
|
||||
|
||||
return map[key];
|
||||
}
|
||||
|
||||
const nlohmann::json & ensureType(
|
||||
const nlohmann::json & value,
|
||||
nlohmann::json::value_type expectedType
|
||||
)
|
||||
{
|
||||
if (value.type() != expectedType)
|
||||
throw Error(
|
||||
"Expected JSON value to be of type '%s' but it is of type '%s'",
|
||||
nlohmann::json(expectedType).type_name(),
|
||||
value.type_name());
|
||||
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,6 +10,28 @@ const nlohmann::json * get(const nlohmann::json & map, const std::string & key);
|
|||
|
||||
nlohmann::json * get(nlohmann::json & map, const std::string & key);
|
||||
|
||||
/**
|
||||
* Get the value of a json object at a key safely, failing
|
||||
* with a Nix Error if the key does not exist.
|
||||
*
|
||||
* Use instead of nlohmann::json::at() to avoid ugly exceptions.
|
||||
*
|
||||
* _Does not check whether `map` is an object_, use `ensureType` for that.
|
||||
*/
|
||||
const nlohmann::json & valueAt(
|
||||
const nlohmann::json & map,
|
||||
const std::string & key);
|
||||
|
||||
/**
|
||||
* Ensure the type of a json object is what you expect, failing
|
||||
* with a Nix Error if it isn't.
|
||||
*
|
||||
* Use before type conversions and element access to avoid ugly exceptions.
|
||||
*/
|
||||
const nlohmann::json & ensureType(
|
||||
const nlohmann::json & value,
|
||||
nlohmann::json::value_type expectedType);
|
||||
|
||||
/**
|
||||
* For `adl_serializer<std::optional<T>>` below, we need to track what
|
||||
* types are not already using `null`. Only for them can we use `null`
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue