Skip to content

Commit

Permalink
support value as leaf node
Browse files Browse the repository at this point in the history
  • Loading branch information
shivaraj-bh committed Aug 21, 2024
1 parent af10904 commit 1d23c1e
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/nix/flake.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "markdown.hh"
#include "users.hh"
#include "flake-schemas.hh"
#include "value-to-json.hh"

#include <nlohmann/json.hpp>
#include <queue>
Expand Down Expand Up @@ -782,6 +783,13 @@ struct CmdFlakeShow : FlakeCommand, MixJSON, flake_schemas::MixFlakeSchemas
if (auto drv = flake_schemas::derivation(leaf))
obj.emplace("derivationName", drv->getAttr(state->sName)->getString());

// TODO: Add a function in flake-schemas.hh to handle this
if (auto value = leaf->maybeGetAttr("value")) {
auto v = value->forceValue();
NixStringContext context;
obj.emplace("value", printValueAsJSON(*state, true, v, noPos, context, false));
}

// FIXME: add more stuff
},

Expand Down

0 comments on commit 1d23c1e

Please sign in to comment.