[Nix-dev] string vs path hell

2014-06-09 Thread Sergey Mironov
Hi. I've faced a path/string problem. Looks like the code lib.splitString "-" (toString (./some/valid/path)) returns [ "./some/valid/path" ] instead of [ "some" "valid" "path" ] in other words, looks like paths are treated in a some special way. Is it a known issue? Regards, Sergey ___

Re: [Nix-dev] string vs path hell

2014-06-09 Thread Luca Bruno
On 09/06/2014 14:32, Sergey Mironov wrote: > lib.splitString "-" (toString (./some/valid/path)) Perhaps you should split by "/" instead of "-"? ___ nix-dev mailing list nix-dev@lists.science.uu.nl http://lists.science.uu.nl/mailman/listinfo/nix-dev

Re: [Nix-dev] string vs path hell

2014-06-09 Thread Sergey Mironov
2014-06-09 16:34 GMT+04:00 Luca Bruno : > On 09/06/2014 14:32, Sergey Mironov wrote: >> lib.splitString "-" (toString (./some/valid/path)) > Perhaps you should split by "/" instead of "-"? Sorry, this is my copypaste mistake. I've meant another file name. The correct code is lib.splitString "/" (

Re: [Nix-dev] string vs path hell

2014-06-09 Thread Luca Bruno
On 09/06/2014 15:01, Sergey Mironov wrote: > 2014-06-09 16:34 GMT+04:00 Luca Bruno : >> On 09/06/2014 14:32, Sergey Mironov wrote: >>> lib.splitString "-" (toString (./some/valid/path)) >> Perhaps you should split by "/" instead of "-"? > Sorry, this is my copypaste mistake. I've meant another file

Re: [Nix-dev] string vs path hell

2014-06-09 Thread Kirill Elagin
Yeah. nix-repl> lib.splitString "/" (toString ./some/vaild/path) [ "" "tmp" "some" "vaild" "path" ] -- Кирилл Елагин On Mon, Jun 9, 2014 at 5:13 PM, Luca Bruno wrote: > On 09/06/2014 15:01, Sergey Mironov wrote: > > 2014-06-09 16:34 GMT+04:00 Luca Bruno : > >> On 09/06/2014 14:32, Sergey Mir

Re: [Nix-dev] string vs path hell

2014-06-09 Thread Sergey Mironov
OK, you are right. My code snippet really works fine. So I feel I must post a part of my real code which still doesn't work for me. It is a bit long, but maybe you will be able to help me find a mistake. Here it is (below). This expression takes a set of paths to the executables (exe // setuids) an

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Kirill Elagin
let lib = (import {}).lib; exe = { foo = "/some/path/to/foo"; bar = "/other/path/to/bar"; }; in { contents = map (v : let takeFileName = p : let fl = lib.splitString "/" p; in lib.last fl; fn = takeFileName

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Kirill Elagin
Oh yeah, I've managed to reproduce this: ~ nix-repl> :l Added 3863 variables. nix-repl> lib.splitString "/" "${pkgs.busybox}/foo/bar" [ "/nix/store/nn00kn1fa0154qa1szszijw825cha8ps-busybox-1.22.1/foo/bar" ] nix-repl> lib.splitString "/" (toString "${pkgs.busybox}/foo/bar") [ "/nix/store/nn0

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Kirill Elagin
Going further: ~~~ nix-repl> a = "${pkgs.busybox}/foo/bar" nix-repl> b = "/nix/store/nn00kn1fa0154qa1szszijw825cha8ps-busybox-1.22.1/foo/bar" nix-repl> a "/nix/store/nn00kn1fa0154qa1szszijw825cha8ps-busybox-1.22.1/foo/bar" nix-repl> b "/nix/store/nn00kn1fa0154qa1szszijw825cha8ps-busybox

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Kirill Elagin
So, here is what I found. Strings in nix have contexts: https://github.com/NixOS/nix/blob/master/src/libexpr/value.hh#L45. When you compare strings with `==`, those contexts also get compared. So, `lib.splitString`, obviously, uses `==` internally to compare substrings with the separator, and si

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Sergey Mironov
Wow, Nix strings are not that simple at all. I'll now go and make my own copy of splitString with '==' replaced by 'lib.eqSttring' as you have suggested. Thanks for the explanation! Sergey 2014-06-10 13:27 GMT+04:00 Kirill Elagin : > So, here is what I found. > > Strings in nix have contexts: > h

Re: [Nix-dev] string vs path hell

2014-06-10 Thread Eelco Dolstra
Hi, On 10/06/14 11:27, Kirill Elagin wrote: > Strings in nix have contexts: > https://github.com/NixOS/nix/blob/master/src/libexpr/value.hh#L45. > When you compare strings with `==`, those contexts also get compared. I've just gotten rid of that: https://github.com/NixOS/nix/commit/ee7fe64c0ac