[Nix-dev] builtins.toPath returns ... a string?

Marc Weber marco-oweber at gmx.de
Thu May 22 17:49:40 CEST 2014


--eval-only --strict -xml output:

of

  {
    s = "/home";
    p = /home;
    to_p = builtins.toPath "/home";
  }

Same

  || <?xml version='1.0' encoding='utf-8'?>
  || <expr>
  ||   <attrs>
  ||     <attr column="3" line="3" name="p" path="/tmp/test.nix">
  ||       <path value="/home" />
  ||     </attr>
  ||     <attr column="3" line="2" name="s" path="/tmp/test.nix">
  ||       <string value="/home" />
  ||     </attr>
  ||     <attr column="3" line="4" name="to_p" path="/tmp/test.nix">
  ||       <string value="/home" />
  ||     </attr>
  ||   </attrs>
  || </expr>


primops.cc

  /* Convert the argument to a path.  !!! obsolete? */
  static void prim_toPath(EvalState & state, const Pos & pos, Value * * args, Value & v)
  {
      PathSet context;
      Path path = state.coerceToPath(pos, *args[0], context);
      mkString(v, canonPath(path), context);
  }

You may want to talk about your use case.

Marc Weber


More information about the nix-dev mailing list