From 37d1b1cafd17a18dc7dbef3b4ba7fb204158d58b Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 10 Mar 2006 16:20:42 +0000 Subject: * `nix-env -qa --description' shows human-readable descriptions of packages (provided that they have a `meta.description' attribute). E.g., $ ./src/nix-env/nix-env -qa --description gcc gcc-4.0.2 GNU Compiler Collection, 4.0.x (cross-compiler for sparc-linux) gcc-4.0.2 GNU Compiler Collection, 4.0.x (cross-compiler for mips-linux) gcc-4.0.2 GNU Compiler Collection, 4.0.x (cross-compiler for arm-linux) gcc-4.0.2 GNU Compiler Collection, 4.0.x --- src/libexpr/get-drvs.cc | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) (limited to 'src/libexpr/get-drvs.cc') diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc index 63e68eb6f489..ff38ff794812 100644 --- a/src/libexpr/get-drvs.cc +++ b/src/libexpr/get-drvs.cc @@ -2,6 +2,49 @@ #include "nixexpr-ast.hh" +string DrvInfo::queryDrvPath(EvalState & state) const +{ + if (drvPath == "") { + Expr a = attrs.get("drvPath"); + (string &) drvPath = a ? evalPath(state, a) : ""; + } + return drvPath; +} + + +string DrvInfo::queryOutPath(EvalState & state) const +{ + if (outPath == "") { + Expr a = attrs.get("outPath"); + if (!a) throw Error("output path missing"); + (string &) outPath = evalPath(state, a); + } + return outPath; +} + + +MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const +{ + MetaInfo meta; + + Expr a = attrs.get("meta"); + if (!a) return meta; /* fine, empty meta information */ + + ATermMap attrs2; + queryAllAttrs(evalExpr(state, a), attrs2); + + for (ATermIterator i(attrs2.keys()); i; ++i) { + ATerm s = coerceToString(evalExpr(state, attrs2.get(*i))); + if (s) + meta[aterm2String(*i)] = aterm2String(s); + /* For future compatibility, ignore attribute values that are + not strings. */ + } + + return meta; +} + + typedef set Exprs; -- cgit 1.4.1