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/
ddellacosta has quit [Ping timeout: 245 seconds]
pie_ has joined #nix-lang
<manveru> man, there are so many cool undocumented builtins :)
<manveru> > builtins.genericClosure { startSet = [{key=10;}]; operator = {key}: if key > 0 then [{key = key - 1;}] else [{inherit key;}]; }
<{^_^}> [ { key = 10; } { key = 9; } { key = 8; } { key = 7; } { key = 6; } { key = 5; } { key = 4; } { key = 3; } { key = 2; } { key = 1; } { key = 0; } ]
<manveru> this one is a bit dangerous too
<EsperLily> huh I haven't seen that one before
<EsperLily> I really wish these builtins had documentation
<manveru> jup
<manveru> 2.3 has builtins.getContext
<EsperLily> I take it genericClosure iterates the operator until it returns its input?
<manveru> yeah
<manveru> i think it does tail-call-optimization, so if you never converge it will break your nix instance
<manveru> don't wanna try here because someone would have to restart the bot i think
<manveru> > builtins.nixVersion
<{^_^}> "2.2.2"
<manveru> sad
<EsperLily> hmm yeah if I run it in nix repl it just hangs forever
<EsperLily> even ^C doesn't work at that point
<manveru> yeah
<EsperLily> d'oh you're right it's not lazy either
<EsperLily> I wrapped it in `builtins.elemAt ... 2` and it's still hanging
<manveru> it was actually commented out in the release notes :P
<manveru> not sure why
<EsperLily> weird
<EsperLily> huh nixpkgs has a deprecated lib.lazyGenericClosure but there's no builtins.lazyGenericClosure
<EsperLily> ok so specifically it uses the required `key` attribute of each set to determine when it's done
<manveru> yeah, so you can pass more arguments
<manveru> that's why its usage is so... cumbersome i guess
<manveru> > __findFile __nixPath "nixpkgs"
<{^_^}> /var/lib/nixbot/nixpkgs/master/repo
<manveru> hum
<manveru> well, not very useful i guess
<manveru> i should maybe do some blog posts about those, love playing with nix :)
<manveru> i like how minimal `derivationStrict` is
<pie_> <manveru> 2.3 has builtins.getContext
<pie_> OMG
<pie_> does that do what i thikn it does
<manveru> yes
<pie_> yessss
<manveru> :D
<pie_> i dont even remember why i wanted that but
<pie_> wait actually no
<pie_> to be clear i was thinking of "get the variables that are in scope"
<manveru> nope
<pie_> ok its the other context
<pie_> what does that get us again? :D
<pie_> infinisil: do you have a watchdog for the bot yet? :D <manveru> don't wanna try here because someone would have to restart the bot i think
<manveru> so... my usecase is something like "<head>${ ./some.css }</head>" in a template, and it'll grab the css, build it, add it to the outputs, and do a string replace for the path with a tag to the file
<pie_> people should get a smack on their hands for not documenting builtins
<pie_> >:(
<manveru> replacing the string also removes the context :)
<manveru> hmmm
<manveru> now i wonder if i can even compile templates that reference nix paths without keeping the reference, or i have to call `unsafeDiscardStringContext` on it
<manveru> would be kinda awkward if you write a blog post about nix with some output and end up deploying it with your blog :P
<pie_> lol
<pie_> actually thats kind of a neat corollary
<pie_> nix:// links or something
<pie_> yooo come and get it from the cacheee
<pie_> my binary cache brings all the boys to the yard
<manveru> pie_: well, that actually works already
__monty__ has joined #nix-lang
<infinisil> manveru: Oh try to run it, I wonder what happens with the bot
noonien has joined #nix-lang
<infinisil> It does restart if it crashes
__monty__ has quit [Ping timeout: 244 seconds]
__monty__ has joined #nix-lang
<manveru> infinisil: thing is that it doesn't crash, but let's see :)
<manveru> > builtins.genericClosure { startSet = [{key = 0;}]; operator = {key}: [{key = key + 1;}]; }
<infinisil> Hehe, yeah this might be problematic
<infinisil> I was hoping it would use more memory over time, but that's not the case
<manveru> it's strange, yeah
<infinisil> I've been wanted to implement a timeout for the nix evaluation for a while
<infinisil> I'm looking at it in htop: 15% CPU usage, 100MB memory
<infinisil> Now 50% (which is the limit it's allowed to)
<infinisil> Kinda weird that it fluctuates with CPU usage
<infinisil> ,ping
<{^_^}> pong
<infinisil> > 1 + 1
<{^_^}> 2
<manveru> well, how many workers does it have ;)
<infinisil> Spawns a new one for every request
<infinisil> But the other one is still going, could definitely DDos it with that :o
* infinisil kills it manually
<{^_^}> (no output)
<manveru> :D
hmpffff has joined #nix-lang
hmpffff has quit [Client Quit]
hmpffff has joined #nix-lang
hmpffff has quit [Quit: Bye…]
ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 245 seconds]
hmpffff has joined #nix-lang
ddellacosta has joined #nix-lang
ddellacosta has quit [Ping timeout: 245 seconds]
__monty__ has quit [Ping timeout: 245 seconds]
__monty__ has joined #nix-lang
sheelx has joined #nix-lang
sheelx has quit [Ping timeout: 272 seconds]
__monty__ has quit [Quit: leaving]
sheelx has joined #nix-lang
hmpffff has quit [Quit: nchrrrr…]
sheelx has quit [Ping timeout: 272 seconds]
sheelx has joined #nix-lang
sheelx has quit [Ping timeout: 246 seconds]