Skip to content

Commit

Permalink
Add pname and version to nix-env -q --json
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasjm committed Jul 28, 2019
1 parent 41a5246 commit cd933b2
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/nix-env/nix-env.cc
Expand Up @@ -860,7 +860,10 @@ static void queryJSON(Globals & globals, vector<DrvInfo> & elems)
for (auto & i : elems) {
JSONObject pkgObj = topObj.object(i.attrPath);

pkgObj.attr("name", i.queryName());
auto drvName = DrvName(i.queryName());
pkgObj.attr("name", drvName.fullName);
pkgObj.attr("pname", drvName.name);
pkgObj.attr("version", drvName.version);
pkgObj.attr("system", i.querySystem());

JSONObject metaObj = pkgObj.object("meta");
Expand Down Expand Up @@ -1026,10 +1029,14 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs)
else if (printAttrPath)
columns.push_back(i.attrPath);

if (xmlOutput)
attrs["name"] = i.queryName();
else if (printName)
if (xmlOutput) {
auto drvName = DrvName(i.queryName());
attrs["name"] = drvName.fullName;
attrs["pname"] = drvName.name;
attrs["version"] = drvName.version;
} else if (printName) {
columns.push_back(i.queryName());
}

if (compareVersions) {
/* Compare this element against the versions of the
Expand Down

0 comments on commit cd933b2

Please sign in to comment.