![]() |
Nix 2.36.0
Nix, the purely functional package manager; unstable internal interfaces
|
Public Member Functions | |
| bool | operator== (const StructuredAttrs &other) const |
| std::pair< std::string_view, std::string > | unparse () const |
| nlohmann::json::object_t | prepareStructuredAttrs (Store &store, const derivation::Options< StorePath > &drvOptions, const StorePathSet &inputPaths, const std::map< std::string, derivation::Output > &outputs) const |
Static Public Member Functions | |
| static StructuredAttrs | parse (std::string_view encoded) |
| static std::optional< StructuredAttrs > | tryExtract (StringPairs &env) |
| static void | checkKeyNotInUse (const StringPairs &env) |
| static std::string | writeShell (const nlohmann::json::object_t &prepared) |
Public Attributes | |
| nlohmann::json::object_t | structuredAttrs |
| std::optional< std::string > | verbatim |
Static Public Attributes | |
| static constexpr std::string_view | envVarName {"__json"} |
|
static |
Ensures that the structured attrs "env var" is not in used, so we are free to use it instead.
| bool nix::StructuredAttrs::operator== | ( | const StructuredAttrs & | other | ) | const |
Compares encodings, not just values, since that is what must round-trip. Dumping is only needed when exactly one side has a verbatim encoding to compare against.
|
static |
Unconditionally parse from a JSON string. Used by tryExtract.
|
static |
Like tryParse, but removes the env var which encoded the structured attrs from the map if one is found.
| std::pair< std::string_view, std::string > nix::StructuredAttrs::unparse | ( | ) | const |
Opposite of tryParse, at least if one makes a map from this single key-value PR.
|
static |
As a convenience to bash scripts, write a shell file that maps all attributes that are representable in bash - namely, strings, integers, nulls, Booleans, and arrays and objects consisting entirely of those values. (So nested arrays or objects are not supported.)
| prepared | This should be the result of prepareStructuredAttrs, not the original structuredAttrs field. |
| std::optional<std::string> nix::StructuredAttrs::verbatim |
The encoding we parsed, kept verbatim because it was not the canonical one unparse would produce. Derivations in the wild predate us caring about this, and their encoding is part of their identity, so we must be able to reproduce it exactly.