Skip to content

Commit ecb62ef

Browse files
committed
nix flake check: Set provenance
1 parent cd388f8 commit ecb62ef

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

src/libcmd/flake-schemas.cc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include "nix/fetchers/fetch-to-store.hh"
44
#include "nix/util/memory-source-accessor.hh"
55
#include "nix/util/mounted-source-accessor.hh"
6+
#include "nix/flake/provenance.hh"
67

78
namespace nix::flake_schemas {
89

@@ -162,12 +163,18 @@ void forEachOutput(
162163
void visit(
163164
std::optional<std::string> system,
164165
ref<AttrCursor> node,
166+
std::shared_ptr<const Provenance> provenance,
165167
std::function<void(const Leaf & leaf)> visitLeaf,
166168
std::function<void(std::function<void(ForEachChild)>)> visitNonLeaf,
167169
std::function<void(ref<AttrCursor> node, const std::vector<std::string> & systems)> visitFiltered)
168170
{
169171
Activity act(*logger, lvlInfo, actUnknown, fmt("evaluating '%s'", node->getAttrPathStr()));
170172

173+
PushProvenance pushedProvenance(
174+
node->root->state,
175+
provenance ? std::make_shared<const FlakeProvenance>(provenance, node->getAttrPathStr(), evalSettings.pureEval)
176+
: nullptr);
177+
171178
/* Apply the system type filter. */
172179
if (system) {
173180
if (auto forSystems = Node(node).forSystems()) {

src/libcmd/include/nix/cmd/flake-schemas.hh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ typedef std::function<void(Symbol attrName, ref<AttrCursor> attr, bool isLast)>
6565
void visit(
6666
std::optional<std::string> system,
6767
ref<AttrCursor> node,
68+
std::shared_ptr<const Provenance> provenance,
6869
std::function<void(const Leaf & leaf)> visitLeaf,
6970
std::function<void(std::function<void(ForEachChild)>)> visitNonLeaf,
7071
std::function<void(ref<AttrCursor> node, const std::vector<std::string> & systems)> visitFiltered);

src/nix/flake.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,7 @@ struct CmdFlakeCheck : FlakeCommand, MixFlakeSchemas
383383
flake_schemas::visit(
384384
checkAllSystems ? std::optional<std::string>() : localSystem,
385385
node,
386+
flake->flake.provenance,
386387

387388
[&](const flake_schemas::Leaf & leaf) {
388389
try {
@@ -899,6 +900,7 @@ struct CmdFlakeShow : FlakeCommand, MixJSON, MixFlakeSchemas
899900
flake_schemas::visit(
900901
showAllSystems ? std::optional<std::string>() : localSystem,
901902
node,
903+
flake->flake.provenance,
902904

903905
[&](const flake_schemas::Leaf & leaf) {
904906
if (auto what = leaf.what())

0 commit comments

Comments
 (0)