infinisil changed the topic of #nix-lang to: Channel for discussing Nix as a language - https://nixos.org/nix/manual/#chap-writing-nix-expressions - Logs: https://logs.nix.samueldr.com/nix-lang/
cfinch has quit [Ping timeout: 260 seconds]
tilpner_ has joined #nix-lang
tilpner has quit [Ping timeout: 260 seconds]
tilpner_ is now known as tilpner
ris has quit [Ping timeout: 260 seconds]
ddellacosta has quit [Ping timeout: 240 seconds]
cfinch has joined #nix-lang
cfinch has quit [Ping timeout: 272 seconds]
cfinch has joined #nix-lang
cfinch has quit [Read error: Connection reset by peer]
cfinch has joined #nix-lang
cfinch has quit [Read error: Connection reset by peer]
cfinch has joined #nix-lang
__monty__ has joined #nix-lang
cfinch has quit [Ping timeout: 272 seconds]
cfinch has joined #nix-lang
ris has joined #nix-lang
niksnut has quit [Remote host closed the connection]
cfinch has quit [Ping timeout: 256 seconds]
cfinch has joined #nix-lang
cfinch has quit [Ping timeout: 260 seconds]
cfinch has joined #nix-lang
noonien has joined #nix-lang
cfinch has quit [Ping timeout: 240 seconds]
cfinch has joined #nix-lang
noonien has quit []
tilpner has quit [Remote host closed the connection]
tilpner has joined #nix-lang
tilpner has quit [Remote host closed the connection]
tilpner has joined #nix-lang
tilpner has quit [Remote host closed the connection]
tilpner has joined #nix-lang
tilpner has quit [Remote host closed the connection]
tilpner has joined #nix-lang
cfinch has quit [Ping timeout: 260 seconds]
cfinch has joined #nix-lang
cfinch has quit [Read error: Connection reset by peer]
cfinch has joined #nix-lang
ddellacosta has joined #nix-lang
<evanjs> Is there like... some sort of helper function to just inject traceSeq or etc everywhere? At least in a specific file? Trying to debug a poetry2nix failure and it's sort of difficult to find the right things to print, label such prints appropriately, etc
__monty__ has quit [Quit: leaving]
<infinisil> evanjs: Nope!
<infinisil> evanjs: Well, there is --trace-function-calls
<infinisil> But I'm not sure how useful that is
<infinisil> It doesn't print any values, so probably not very much
<evanjs> mmmmm undocumented options :P
<evanjs> okay, easier question -- how can I get something like traceVal but with the name? `trace "name" thing` doesn't always print out everything, I have to manage types and etc for trace...Fn, etc
<evanjs> I just want the output to be labeled so I know what I'm looking at
<infinisil> evanjs: I guess a helper function for that might be nice
<evanjs> infinisil: yeah I wanted to make sure I wasn't missing anything/something like that doesn't already exist
<infinisil> Hm maybe like a general logging framework for nix might be nice
<infinisil> Or even better, what if Nix had a mode where it showed everything it evaluated, step-by-step
<evanjs> ^^^ yes please. yak shaving ftw... I just thought I'd try packaging a python app this weekend. Aaaand now we're talking about a logging framework for nix x_x XD
<evanjs> ^ also that
<evanjs> like the nixUnstable --show-trace is a wonderful improvement, but I think your second option would basically solve the rest of my debugging issues 99% of the time
<infinisil> I've been pretty involved with Nix's evaluation code for https://github.com/NixOS/nix/pull/4154 :D
<{^_^}> nix#4154 (by Infinisil, 1 day ago, open): [WIP] Lazy attribute names
<infinisil> And that sounds doable
<evanjs> was just looking at nixpkgs#98761 -- so many big PRs open :o (drafts, but stillll)
<{^_^}> https://github.com/NixOS/nixpkgs/pull/98761 (by Infinisil, 3 weeks ago, open): Streaming `toPretty`
<infinisil> Hehe
<infinisil> Yeah about that toPretty, it might be pretty hard to split it into more functions
<infinisil> And tbh, the gain of that change isn't that great
<infinisil> (but I love it)
<evanjs> Yeah I saw Profpatsch's comment. Definitely interested in any sort of potential prettification with nix stuffs
<infinisil> This does: If the prettyprint result is only one line, it prints that without a \n. If it's multiple, it prints them on multiple lines. And if there's more than 5, it prints a "..." line
<infinisil> All with just this single function!
<evanjs> gahhh I need this
<infinisil> evanjs: Oh you do?
<infinisil> I actually did some experiments with a Nix function that allows you to have imperative loops you can break out of
<infinisil> Let's see..
<infinisil> > iterate = arg1: arg2: arg3: if lib.isFunction arg3 then let result = builtins.foldl' (acc: index: if acc ? __return then acc else arg3 acc index ) arg1 arg2; in result else arg4: let result = builtins.foldl' (acc: index: if acc ? __return then acc else arg4 (val: { __return.${arg1} = val; }) acc index ) arg2 arg3; in result.__return.${arg1} or result
<{^_^}> iterate defined
<infinisil> There
<evanjs> what in the world haha
<infinisil> > iterate 0 [ 1 2 3 ] (state: element: state + element)
<{^_^}> 6
<infinisil> This is what it does basically
<infinisil> But!
<infinisil> > iterate "loop" 0 [ 1 2 3 4 5 ] (continue: state: element: if state > 6 then continue else state + element)
<{^_^}> <LAMBDA>
<infinisil> > iterate "loop" 0 [ 1 2 3 4 5 ] (continue: state: element: if state > 6 then continue state else state + element)
<{^_^}> 10
<infinisil> You can break out of it, like a `continue;` statement!
<infinisil> Here it summed values until it got to a value greater than 6, then stopped
<evanjs> ahhh like conditional breakpoints and etc
<infinisil> And you can even nest them!
<infinisil> I could now have another iterate in the upper iterate
<infinisil> And at any point I could choose to break out of either iteration
<evanjs> another random thought.... I wonder if it'd be possible for `nix repl` to have a "keep evaluated variables". Like -K, but for failed evaluations :P
<evanjs> So I don't have to input all the stuff leading up to whatever failed manually, etc
<infinisil> Oh so like a debugger
<infinisil> breakpoints
<infinisil> That sure would be nice
<evanjs> especially since repl doesn't like some semicolons, so I can't easily import multiple functions or etc at a time
<infinisil> Hmmmm I'm just thinking about how easy it would be to add this to nix
<infinisil> It might actually be pretty easy
<infinisil> Just a thing that gives you a nix repl in case of an error, with all variables at that point in scope
<evanjs> I'm great with random ideas like that, but it's always difficult when it comes to rationale, who needs it, blabla
<evanjs> and yes, that sounds like exactly what I'd need
<infinisil> Everybody needs that!
<infinisil> Nix is currently a pain to debug
<evanjs> nixUnstable show-trace is such an improvement I've been trying to use it whenever I can, but yeah, several little(?) things that would drastically improve the debugging experience
<infinisil> Hm, tbh I'm not yet a big fan of unstable show-trace
<infinisil> Because it shows a bit too much
<evanjs> oh for sure
<infinisil> Also, I think it inversed the order of traces
<infinisil> Hm did it?
<evanjs> the normal output that shows the several lines of context alone is way more helpful though
<evanjs> and the colorsss
<infinisil> Agreed
<infinisil> Hm also, nix repl should probably be able to have a command for showing the definitions of variables
<infinisil> Like the :v in the bot here, but builtin