mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-25 23:36:16 +02:00
Merge pull request #9257 from Artturin/nixenvjsondrvpath
`nix-env --query`: fix `--json` ignoring `--drv-path`
This commit is contained in:
commit
516e7ddc41
3 changed files with 9 additions and 2 deletions
|
@ -1,2 +1,3 @@
|
||||||
# Release X.Y (202?-??-??)
|
# Release X.Y (202?-??-??)
|
||||||
|
|
||||||
|
- Fixed a bug where `nix-env --query` ignored `--drv-path` when `--json` was set.
|
|
@ -922,7 +922,7 @@ static VersionDiff compareVersionAgainstSet(
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printMeta)
|
static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool printOutPath, bool printDrvPath, bool printMeta)
|
||||||
{
|
{
|
||||||
using nlohmann::json;
|
using nlohmann::json;
|
||||||
json topObj = json::object();
|
json topObj = json::object();
|
||||||
|
@ -953,6 +953,11 @@ static void queryJSON(Globals & globals, std::vector<DrvInfo> & elems, bool prin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (printDrvPath) {
|
||||||
|
auto drvPath = i.queryDrvPath();
|
||||||
|
if (drvPath) pkgObj["drvPath"] = globals.state->store->printStorePath(*drvPath);
|
||||||
|
}
|
||||||
|
|
||||||
if (printMeta) {
|
if (printMeta) {
|
||||||
json &metaObj = pkgObj["meta"];
|
json &metaObj = pkgObj["meta"];
|
||||||
metaObj = json::object();
|
metaObj = json::object();
|
||||||
|
@ -1079,7 +1084,7 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
|
||||||
|
|
||||||
/* Print the desired columns, or XML output. */
|
/* Print the desired columns, or XML output. */
|
||||||
if (jsonOutput) {
|
if (jsonOutput) {
|
||||||
queryJSON(globals, elems, printOutPath, printMeta);
|
queryJSON(globals, elems, printOutPath, printDrvPath, printMeta);
|
||||||
cout << '\n';
|
cout << '\n';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ nix-env -f ./user-envs.nix -qa --json --out-path | jq -e '.[] | select(.name ==
|
||||||
.outputName == "out",
|
.outputName == "out",
|
||||||
(.outputs.out | test("'$NIX_STORE_DIR'.*-0\\.1"))
|
(.outputs.out | test("'$NIX_STORE_DIR'.*-0\\.1"))
|
||||||
] | all'
|
] | all'
|
||||||
|
nix-env -f ./user-envs.nix -qa --json --drv-path | jq -e '.[] | select(.name == "bar-0.1") | (.drvPath | test("'$NIX_STORE_DIR'.*-0\\.1\\.drv"))'
|
||||||
|
|
||||||
# Query descriptions.
|
# Query descriptions.
|
||||||
nix-env -f ./user-envs.nix -qa '*' --description | grepQuiet silly
|
nix-env -f ./user-envs.nix -qa '*' --description | grepQuiet silly
|
||||||
|
|
Loading…
Reference in a new issue