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 joined #nix-lang
{^_^} has quit [Read error: Connection reset by peer]
{^_^} has joined #nix-lang
Synthetica has quit [Quit: Connection closed for inactivity]
ddellacosta has quit [Ping timeout: 272 seconds]
pie_ has quit [Ping timeout: 252 seconds]
Synthetica has joined #nix-lang
__monty__ has joined #nix-lang
pie_ has joined #nix-lang
pie_ has quit [Remote host closed the connection]
pie_ has joined #nix-lang
pie_ has quit [Ping timeout: 258 seconds]
pie_ has joined #nix-lang
pie_ has quit [Remote host closed the connection]
pie_ has joined #nix-lang
pie___ has joined #nix-lang
pie_ has quit [Ping timeout: 248 seconds]
pie___ has quit [Remote host closed the connection]
pie___ has joined #nix-lang
pie_ has joined #nix-lang
pie___ has quit [Ping timeout: 246 seconds]
__monty__ has quit [Ping timeout: 258 seconds]
noonien has joined #nix-lang
pie_ has quit [Ping timeout: 248 seconds]
pie_ has joined #nix-lang
{^_^} has quit [Remote host closed the connection]
{^_^} has joined #nix-lang
<pie_> is there a reasonable way to limit what can be passed to root.withPackages (p: with p; [ a b c ]) in the list?
<pie_> id like to limit the contents of the list to be attributes from the scope p
<pie_> i guess i could require strings and then use that to index into p, but thats not that nice
<infinisil> pie_: You could make it `root.withPackages { a = true; b = true; c = true; }`
<infinisil> Not very nice either though
<pie_> problem is i dont see how i could prevent something from creeping in from the defining scope of the expression
<pie_> somethign something i think these are called closures?
<infinisil> > let withPackages = selector: selector { a = "a"; b = "b"; c = "c"; }; in withPackages (p: with p; [ a b c ])
<{^_^}> [ 10 10 <CODE> ]
<infinisil> How about this
<infinisil> (let's ignore a and b being defined already)
<infinisil> Then people can pass in anything they want, but you only accept the strings they already get through the argument
<pie_> oh, clever, hacky (which is probably unavoidable in this case), but i think i like it
<pie_> horrors of implementation, for the sake of ergonomics! :P
<infinisil> But do you really want that? Often it's convenient to pass in things from outside
<pie_> yeah but then i shot myself in the foot when there was a name collision
<pie_> i thought the with would take precedence but it didnt
<pie_> i had nixpkgs in scope on the repl
<infinisil> let's take indeed precedence over with's
<infinisil> And I guess in nix repl, :l/:a is like a let
<pie_> which is roughly what i figured
<pie_> i just didnt even realize something was already named the thing i wanted to use
<pie_> and it gave a really weird error
<pie_> (build time)
ddellacosta has joined #nix-lang