[Nix-dev] Re: the string .. is not allowed to refer to a store path

Marc Weber marco-oweber at gmx.de
Sat Sep 26 00:19:26 CEST 2009


Excerpts from Marc Weber's message of Fri Sep 25 20:47:57 +0200 2009:
> 
> # args@{...} should work, but isn't implemented yet :-(
> { system ? builtins.currentSystem
> , stdenvType ? system
> , bootStdenv ? null
> , noSysDirs ? true
> , gccWithCC ? true
> , gccWithProfiling ? true
> , config ? null
> }:
> 
> let 
>     args = { inherit system stdenvType bootStdenv noSysDirs gccWithCC
> gccWithProfiling config; };
>     pkgs = import ./all-packages.nix args;
> 
> in listToAttrs [{ name = substring 11 3000 "${pkgs.MPlayer.outPath}"; value =
> pkgs.MPlayer; }]
> 
> 
> when running nix-build -A somePackage  $THE_FILE_ABOVE
> 
> it fails with:
> 
> 
>  marc i%nix-env --show-trace -iA MPlayerTrunk -f
> /pr/gitnixdev/nixpkgs/pkgs/top-level/all-packages-post.nix
> error: while evaluating the function at
> `/pr/gitnixdev/nixpkgs/pkgs/top-level/all-packages-post.nix:28:2':
> while evaluating the attribute `<let-body>' at
> `/pr/gitnixdev/nixpkgs/pkgs/top-level/all-packages-post.nix:37:4':
> in `listToAttrs':
> the string `2j053fyipv0blxjhrr6b0zj8vqa1m2bw-MPlayer-1.0rc2-r28450' is not
> allowed to refer to a store path (such as
> `/nix/store/k807gmpg6hz5f23azqjlgnn7xkkvfjma-MPlayer-1.0rc2-r28450.drv') 


Is it safe to replace evalStringNoCtx by evalString passing a new PathSet context ?

Eg this patch makes the error above go away:

Marc Weber

commit 9a345bc772e5cb5ea7297b7afe039032dc90bb6c
Author: Marc Weber <marco-oweber at gmx.de>
Date:   Fri Sep 25 21:34:16 2009 +0200

    allow store paths as attr names

diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index 783d26c..4f0faee 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -742,7 +742,8 @@ static Expr prim_attrNames(EvalState & state, const ATermVector & args)
 /* Dynamic version of the `.' operator. */
 static Expr prim_getAttr(EvalState & state, const ATermVector & args)
 {
-    string attr = evalStringNoCtx(state, args[0]);
+  PathSet context; // I don't really know what I'm doing here. I PathSet is used whenever evalString is used instead of evalStringNoCtx ..
+    string attr = evalString(state, args[0], context);
     return evalExpr(state, makeSelect(args[1], toATerm(attr)));
 }
 
@@ -750,7 +751,8 @@ static Expr prim_getAttr(EvalState & state, const ATermVector & args)
 /* Dynamic version of the `?' operator. */
 static Expr prim_hasAttr(EvalState & state, const ATermVector & args)
 {
-    string attr = evalStringNoCtx(state, args[0]);
+    PathSet context; // I don't really know what I'm doing here. I PathSet is used whenever evalString is used instead of evalStringNoCtx ..
+    string attr = evalString(state, args[0], context);
     return evalExpr(state, makeOpHasAttr(args[1], toATerm(attr)));
 }
 
@@ -771,7 +773,8 @@ static Expr prim_listToAttrs(EvalState & state, const ATermVector & args)
             Expr evaledExpr = evalExpr(state, *i);
             if (matchAttrs(evaledExpr, attrs)){
                 Expr e = evalExpr(state, makeSelect(evaledExpr, toATerm("name")));
-                string attr = evalStringNoCtx(state,e);
+                PathSet context; // I don't really know what I'm doing here. I PathSet is used whenever evalString is used instead of evalStringNoCtx ..
+                string attr = evalString(state, e, context);
                 Expr r = makeSelect(evaledExpr, toATerm("value"));
                 res.set(toATerm(attr), makeAttrRHS(r, makeNoPos()));
             }



More information about the nix-dev mailing list