mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
Merge f68a3023cd
into 6a74590063
This commit is contained in:
commit
a0f44261e5
2 changed files with 22 additions and 6 deletions
|
@ -1459,7 +1459,8 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
|
|||
|
||||
auto cache = openEvalCache(*state, flake);
|
||||
|
||||
auto j = visit(*cache->getRoot(), {}, fmt(ANSI_BOLD "%s" ANSI_NORMAL, flake->flake.lockedRef), "");
|
||||
auto lockedRef = flake->flake.lockedRef.to_string();
|
||||
auto j = nlohmann::json::object({ {lockedRef, visit(*cache->getRoot(), {}, fmt(ANSI_BOLD "%s" ANSI_NORMAL, lockedRef), "")} });
|
||||
if (json)
|
||||
printJSON(j);
|
||||
}
|
||||
|
|
|
@ -8,10 +8,25 @@ mkdir -p "$flakeDir"
|
|||
writeSimpleFlake "$flakeDir"
|
||||
pushd "$flakeDir"
|
||||
|
||||
# Check the flake reference that was produced.
|
||||
nix flake show --json > output.json
|
||||
nix eval --impure --expr '
|
||||
with builtins;
|
||||
let
|
||||
flakeRef = parseFlakeRef (head (attrNames (fromJSON (readFile ./output.json))));
|
||||
narHash = if match ".*darwin" currentSystem != null
|
||||
then "sha256-MhmXWT9U41eDFezA02mAj3PxBO21icT5VvvPSC1epDU="
|
||||
else "sha256-op9gWTEmDXergxx2PojSTrxVREG7NLcrhySSun3DQd0="
|
||||
;
|
||||
in
|
||||
assert flakeRef.narHash == narHash;
|
||||
assert flakeRef.type == "path";
|
||||
true
|
||||
'
|
||||
|
||||
# By default: Only show the packages content for the current system and no
|
||||
# legacyPackages at all
|
||||
nix flake show --json > show-output.json
|
||||
nix flake show --json | jq 'to_entries[0].value' > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
|
@ -22,7 +37,7 @@ true
|
|||
'
|
||||
|
||||
# With `--all-systems`, show the packages for all systems
|
||||
nix flake show --json --all-systems > show-output.json
|
||||
nix flake show --json --all-systems | jq 'to_entries[0].value' > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
|
@ -32,7 +47,7 @@ true
|
|||
'
|
||||
|
||||
# With `--legacy`, show the legacy packages
|
||||
nix flake show --json --legacy > show-output.json
|
||||
nix flake show --json --legacy | jq 'to_entries[0].value' > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
|
@ -59,7 +74,7 @@ cat >flake.nix <<EOF
|
|||
};
|
||||
}
|
||||
EOF
|
||||
nix flake show --json --all-systems > show-output.json
|
||||
nix flake show --json --all-systems | jq 'to_entries[0].value' > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
|
@ -79,7 +94,7 @@ cat >flake.nix <<EOF
|
|||
};
|
||||
}
|
||||
EOF
|
||||
nix flake show --json --legacy --all-systems > show-output.json
|
||||
nix flake show --json --legacy --all-systems | jq 'to_entries[0].value' > show-output.json
|
||||
nix eval --impure --expr '
|
||||
let show_output = builtins.fromJSON (builtins.readFile ./show-output.json);
|
||||
in
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue