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

2014-05-22 Thread Ben Doyle
I've been writing some nix functions that used `builtins.toPath`, and
getting some strange error messages. That led to the following repl session:

nix-repl :t /home
a string

nix-repl :t /home
a path

nix-repl :t builtins.toPath /home
a string

That has to be a bug, no? Or am I totally misunderstanding the purpose of
`builtins.tPath`?

Ben
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


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

2014-05-22 Thread Marc Weber
--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
___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


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

2014-05-22 Thread Kirill Elagin
The relevant commit is this:
https://github.com/NixOS/nix/commit/d7efd7639420f4c840cbfdfcbbb3c45292f3ac54
Looks like `toPath` is not only obsolete, but prohibited since semantics of
paths changed and now it makes no sense no convert something to a path.


--
Кирилл Елагин


On Thu, May 22, 2014 at 7:49 PM, Marc Weber marco-owe...@gmx.de wrote:

 --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
 ___
 nix-dev mailing list
 nix-dev@lists.science.uu.nl
 http://lists.science.uu.nl/mailman/listinfo/nix-dev

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev


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

2014-05-22 Thread Shea Levy
Possibly relevant discussion: https://github.com/NixOS/nix/pull/47
On Thu, May 22, 2014 at 09:04:19PM +0400, Kirill Elagin wrote:
 The relevant commit is this:
 https://github.com/NixOS/nix/commit/d7efd7639420f4c840cbfdfcbbb3c45292f3ac54
 Looks like `toPath` is not only obsolete, but prohibited since semantics of
 paths changed and now it makes no sense no convert something to a path.
 
 
 --
 Кирилл Елагин
 
 
 On Thu, May 22, 2014 at 7:49 PM, Marc Weber marco-owe...@gmx.de wrote:
 
  --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
  ___
  nix-dev mailing list
  nix-dev@lists.science.uu.nl
  http://lists.science.uu.nl/mailman/listinfo/nix-dev
 

 ___
 nix-dev mailing list
 nix-dev@lists.science.uu.nl
 http://lists.science.uu.nl/mailman/listinfo/nix-dev

___
nix-dev mailing list
nix-dev@lists.science.uu.nl
http://lists.science.uu.nl/mailman/listinfo/nix-dev