mirror of
https://github.com/NixOS/nix
synced 2025-06-25 06:31:14 +02:00
nix flake metadata: Show store path if available
This commit is contained in:
parent
d0a89fa03f
commit
f6ad6291ab
2 changed files with 7 additions and 2 deletions
|
@ -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;
|
||||
|
|
|
@ -69,6 +69,7 @@ nix flake metadata "$flake1Dir" | grepQuiet 'URL:.*flake1.*'
|
|||
# Test 'nix flake metadata --json'.
|
||||
json=$(nix flake metadata flake1 --json | jq .)
|
||||
[[ $(echo "$json" | jq -r .description) = 'Bla bla' ]]
|
||||
[[ -d $(echo "$json" | jq -r .path) ]]
|
||||
[[ $(echo "$json" | jq -r .lastModified) = $(git -C "$flake1Dir" log -n1 --format=%ct) ]]
|
||||
hash1=$(echo "$json" | jq -r .revision)
|
||||
[[ -n $(echo "$json" | jq -r .fingerprint) ]]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue