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/
andi- has quit [Ping timeout: 246 seconds]
andi- has joined #nix-lang
ddellacosta has quit [Ping timeout: 256 seconds]
__monty__ has joined #nix-lang
ddellacosta has joined #nix-lang
ddellacosta has quit [Quit: WeeChat 2.2]
ddellacosta has joined #nix-lang
evanjs has quit [Quit: ZNC 1.7.5 - https://znc.in]
evanjs has joined #nix-lang
Vikingman has quit [Read error: Connection reset by peer]
kyren has quit [Ping timeout: 256 seconds]
ddellacosta has quit [Ping timeout: 264 seconds]
ddellacosta has joined #nix-lang
<infinisil> > let exists = _: if result ? key then "exists" else "doesn't"; result = { ${exists 0} = null; ${"key" + ""} = null; ${exists 0} = null; }; in result
<{^_^}> { doesn't = null; exists = null; key = null; }
<infinisil> puck: ^ :o
<infinisil> > let exists = _: if result ? key then "exists" else "doesn't"; result = { ${exists 0} = null; ${exists 0} = null; ${"key" + ""} = null; }; in result
<{^_^}> dynamic attribute 'doesn't' at (string):292:94 already defined at (string):292:74
adisbladis has joined #nix-lang
__monty__ has quit [Quit: leaving]
drakonis has joined #nix-lang
<puck> nice, that's a derivative of https://github.com/NixOS/nix/issues/3241 i suspect
<{^_^}> nix#3241 (by puckipedia, 17 weeks ago, open): Attribute set can be observed while in an incomplete state
<{^_^}> nix#3078 (by puckipedia, 29 weeks ago, open): primop evaluation inside attrset keys doesn't work properly
<puck> (they're kinda the same issue in general)
<infinisil> Ah yes, nice :D
<infinisil> I think dynamic attribute keys in general is the problematic feature
<puck> dw, i can have dynamic attribute keys without dynamic attribute keys
<puck> :p
<puck> > let makeAttr = name: value: import (builtins.toFile "a" "value: { ${builtins.toJSON name} = value; }") value; in makeAttr "foo" "bar"
<{^_^}> cannot import '/nix/store/4sjqj2nnmhylsncdq2l534149w75sh9y-a', since path '/nix/store/4sjqj2nnmhylsncdq2l534149w75sh9y-a' is not valid, at (string):292:29
<puck> thanks {`-`}_
<puck> err
<puck> thanks {^_^}
<puck> (read-only store :( )
bachp has joined #nix-lang
<puck> also this is not completely functional in general, obvs
<infinisil> Hehe
<puck> tbh i'm not sure there's anything in nixlang that would really surprise me anymore
<infinisil> puck: But I think just `builtins.listToAttrs` would work
<puck> infinisil: ssh
<infinisil> Yeah nix has some weird corners
<puck> infinisil: i assume you've seen the weirdness with rec and non-rec
<infinisil> Possibly
<puck> > let a = rec {}; b = 5; a.b = b; in a.b
<{^_^}> infinite recursion encountered, at (string):292:30
<puck> or even weirder
<infinisil> Oh yeah, but I don't know what's going on
<puck> > let a = rec {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}> infinite recursion encountered, at (string):292:38
<puck> recness of an attrset is defined once it is first declared, and the shorthand for attrset building does not handle this properly
<puck> i'm not entirely certain this is easily fixable in Nix
<infinisil> I feel like that expression should just give an error that a is assigned multiple times
<puck> except
<puck> hrm
<puck> like, this is continuation of attrset shorthands
<puck> e.g. > let a = { b = 5; }; a.c = 7; in a
<puck> is valid
<infinisil> Hm
<infinisil> Maybe rec shouldn't be allowed to take part in this
<puck> that'd probably break things that exist already
<infinisil> Eh
<puck> it shouldn't be too hard (is it? idk) to throw a warning when this generates a conflicting scope tho
<infinisil> Wait wouldn't it make sense for `rec {} == {}`?
<infinisil> > let a = rec {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}> infinite recursion encountered, at (string):292:38
<infinisil> > let a = {}; a = {}; b = 5; a.b = b; in a.b
<{^_^}> 5
<infinisil> Have a rewrite pass, that transforms all recs into non-rec variants
<infinisil> > rec { a = 10; b = a; }
<{^_^}> { a = 10; b = 10; }
<infinisil> > let a = 10; b = a; in { inherit a b; } # Turns into this
<{^_^}> { a = 10; b = 10; }
<puck> this isn't too hard to do in general but definitely in the current nix codebase
evanjs has quit [Quit: ZNC 1.7.5 - https://znc.in]
evanjs has joined #nix-lang