|
18 | 18 | #include "nix/fetchers/fetch-to-store.hh" |
19 | 19 | #include "nix/util/sort.hh" |
20 | 20 | #include "nix/util/mounted-source-accessor.hh" |
| 21 | +#include "nix/expr/provenance.hh" |
21 | 22 |
|
22 | 23 | #include <boost/container/small_vector.hpp> |
23 | 24 | #include <boost/unordered/concurrent_flat_map.hpp> |
@@ -1504,6 +1505,8 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName |
1504 | 1505 | StringSet outputs; |
1505 | 1506 | outputs.insert("out"); |
1506 | 1507 |
|
| 1508 | + auto provenance = state.evalContext.provenance; |
| 1509 | + |
1507 | 1510 | for (auto & i : attrs->lexicographicOrder(state.symbols)) { |
1508 | 1511 | if (i->name == state.s.ignoreNulls) |
1509 | 1512 | continue; |
@@ -1571,6 +1574,24 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName |
1571 | 1574 | experimentalFeatureSettings.require(Xp::ImpureDerivations); |
1572 | 1575 | } |
1573 | 1576 | break; |
| 1577 | + case EvalState::s.meta.getId(): |
| 1578 | + experimentalFeatureSettings.require(Xp::Provenance); |
| 1579 | + |
| 1580 | + { |
| 1581 | + auto meta = printValueAsJSON(state, true, *i->value, pos, context); |
| 1582 | + |
| 1583 | + for (auto it = meta.begin(); it != meta.end();) { |
| 1584 | + if (it.key() == "identifiers" || it.key() == "license" || it.key() == "licenses") { |
| 1585 | + it++; |
| 1586 | + continue; |
| 1587 | + } |
| 1588 | + |
| 1589 | + it = meta.erase(it); |
| 1590 | + } |
| 1591 | + |
| 1592 | + provenance = std::make_shared<const MetaProvenance>(provenance, make_ref<nlohmann::json>(meta)); |
| 1593 | + } |
| 1594 | + break; |
1574 | 1595 | /* The `args' attribute is special: it supplies the |
1575 | 1596 | command-line arguments to the builder. */ |
1576 | 1597 | case EvalState::s.args.getId(): |
@@ -1847,8 +1868,7 @@ static void derivationStrictInternal(EvalState & state, std::string_view drvName |
1847 | 1868 | } |
1848 | 1869 |
|
1849 | 1870 | /* Write the resulting term into the Nix store directory. */ |
1850 | | - auto drvPath = |
1851 | | - writeDerivation(*state.store, *state.asyncPathWriter, drv, state.repair, false, state.evalContext.provenance); |
| 1871 | + auto drvPath = writeDerivation(*state.store, *state.asyncPathWriter, drv, state.repair, false, provenance); |
1852 | 1872 | auto drvPathS = state.store->printStorePath(drvPath); |
1853 | 1873 |
|
1854 | 1874 | printMsg(lvlChatty, "instantiated '%1%' -> '%2%'", drvName, drvPathS); |
@@ -5420,7 +5440,14 @@ void EvalState::createBaseEnv(const EvalSettings & evalSettings) |
5420 | 5440 | language feature gets added. It's not necessary to increase it |
5421 | 5441 | when primops get added, because you can just use `builtins ? |
5422 | 5442 | primOp' to check. */ |
5423 | | - v.mkInt(6); |
| 5443 | + if (experimentalFeatureSettings.isEnabled(Xp::Provenance)) { |
| 5444 | + /* Provenance allows for meta to be inside of derivations. |
| 5445 | + We increment the version to 7 so Nixpkgs will know when |
| 5446 | + provenance is available. */ |
| 5447 | + v.mkInt(7); |
| 5448 | + } else { |
| 5449 | + v.mkInt(6); |
| 5450 | + } |
5424 | 5451 | addConstant( |
5425 | 5452 | "__langVersion", |
5426 | 5453 | v, |
|
0 commit comments