aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libstore/derivations.cc8
-rw-r--r--src/libstore/derivations.hh1
-rw-r--r--src/libstore/tests/derivation.cc3
-rw-r--r--src/nix/show-derivation.md3
4 files changed, 11 insertions, 4 deletions
diff --git a/src/libstore/derivations.cc b/src/libstore/derivations.cc
index ea4abb352..9f74f1c30 100644
--- a/src/libstore/derivations.cc
+++ b/src/libstore/derivations.cc
@@ -988,6 +988,8 @@ nlohmann::json Derivation::toJSON(const Store & store) const
{
nlohmann::json res = nlohmann::json::object();
+ res["name"] = name;
+
{
nlohmann::json & outputsObj = res["outputs"];
outputsObj = nlohmann::json::object();
@@ -1020,17 +1022,19 @@ nlohmann::json Derivation::toJSON(const Store & store) const
Derivation Derivation::fromJSON(
- const Store & store, std::string_view drvName,
+ const Store & store,
const nlohmann::json & json)
{
Derivation res;
+ res.name = json["name"];
+
{
auto & outputsObj = json["outputs"];
for (auto & [outputName, output] : outputsObj.items()) {
res.outputs.insert_or_assign(
outputName,
- DerivationOutput::fromJSON(store, drvName, outputName, output));
+ DerivationOutput::fromJSON(store, res.name, outputName, output));
}
}
diff --git a/src/libstore/derivations.hh b/src/libstore/derivations.hh
index 0722dc61d..38727d77a 100644
--- a/src/libstore/derivations.hh
+++ b/src/libstore/derivations.hh
@@ -340,7 +340,6 @@ struct Derivation : BasicDerivation
nlohmann::json toJSON(const Store & store) const;
static Derivation fromJSON(
const Store & store,
- std::string_view drvName,
const nlohmann::json & json);
GENERATE_CMP(Derivation,
diff --git a/src/libstore/tests/derivation.cc b/src/libstore/tests/derivation.cc
index 8993cd80b..80ee52fd0 100644
--- a/src/libstore/tests/derivation.cc
+++ b/src/libstore/tests/derivation.cc
@@ -98,12 +98,12 @@ TEST_JSON(impure,
Derivation { VAL }, \
Derivation::fromJSON( \
*store, \
- DRV_NAME, \
STR ## _json)); \
}
TEST_JSON(simple,
R"({
+ "name": "my-derivation",
"inputSrcs": [
"/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"
],
@@ -126,6 +126,7 @@ TEST_JSON(simple,
})",
({
Derivation drv;
+ drv.name = "my-derivation";
drv.inputSrcs = {
store->parseStorePath("/nix/store/c015dhfh5l0lp6wxyvdn7bmwhbbr6hr9-dep1"),
};
diff --git a/src/nix/show-derivation.md b/src/nix/show-derivation.md
index 1d37c6f5a..17d88a5f9 100644
--- a/src/nix/show-derivation.md
+++ b/src/nix/show-derivation.md
@@ -51,6 +51,9 @@ The JSON output is a JSON object whose keys are the store paths of the
derivations, and whose values are a JSON object with the following
fields:
+* `name`: The name of the derivation. This is used when calculating the
+ store paths of the derivation's outputs.
+
* `outputs`: Information about the output paths of the
derivation. This is a JSON object with one member per output, where
the key is the output name and the value is a JSON object with these