From 4921223160ebde522b8362c46e8f962fc09878ac Mon Sep 17 00:00:00 2001 From: Pascal Wittmann Date: Sat, 21 Nov 2015 11:43:44 +0100 Subject: [PATCH] Print license information on '--xml --meta' The nixpkgs manual prescribes the use of values from stdenv.lib.licenses for the meta.license attribute. Those values are attribute sets and currently skipped when running nix-env with '--xml --meta'. This has the consequence that also nixpkgs-lint will report missing licenses. With this commit nix-env with '--xml --meta' will print all attributes of an attribute set that are of type tString. For example the output for the package nixpkgs.hello is This commit fixes nixpkgs-lint, too. --- src/nix-env/nix-env.cc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/nix-env/nix-env.cc b/src/nix-env/nix-env.cc index 313f8a8a8..02a9f25a7 100644 --- a/src/nix-env/nix-env.cc +++ b/src/nix-env/nix-env.cc @@ -1140,7 +1140,19 @@ static void opQuery(Globals & globals, Strings opFlags, Strings opArgs) attrs3["value"] = v->listElems()[j]->string.s; xml.writeEmptyElement("string", attrs3); } + } else if (v->type == tAttrs) { + attrs2["type"] = "strings"; + XMLOpenElement m(xml, "meta", attrs2); + Bindings & attrs = *v->attrs; + for (auto &i : attrs) { + Attr & a(*attrs.find(i.name)); + if(a.value->type != tString) continue; + XMLAttrs attrs3; + attrs3["type"] = i.name; + attrs3["value"] = a.value->string.s; + xml.writeEmptyElement("string", attrs3); } + } } } }