1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-21 01:39:36 +01:00

nix flake metadata: Show store path if available

This commit is contained in:
Eelco Dolstra 2025-05-07 15:56:35 +02:00
parent d0a89fa03f
commit f6ad6291ab
2 changed files with 7 additions and 2 deletions

View file

@ -218,9 +218,13 @@ struct CmdFlakeMetadata : FlakeCommand, MixJSON
auto lockedFlake = lockFlake();
auto & flake = lockedFlake.flake;
/* Hack to show the store path if available. */
std::optional<StorePath> storePath;
if (flake.lockedRef.input.getNarHash())
storePath = flake.lockedRef.input.computeStorePath(*store);
if (store->isInStore(flake.path.path.abs())) {
auto path = store->toStorePath(flake.path.path.abs()).first;
if (store->isValidPath(path))
storePath = path;
}
if (json) {
nlohmann::json j;