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/
<gchristensen> inherit ({builtins = null; }) builtins;
<gchristensen> >> inherit ({builtins = null; }) builtins;
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<gchristensen> >> inherit ({builtins = null; }) builtins
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<infinisil> >> 1
<{^_^}> 1
<infinisil> >> inherit (pkgs) hello
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<infinisil> Hum, I thought inherit's should work too
<infinisil> >> inherit x
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<infinisil> > inherit x
<{^_^}> error: syntax error, unexpected INHERIT, at (string):193:1
<infinisil> >> inherit x
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<infinisil> >> inherit (pkgs) x
<{^_^}> error: NixParseFailure "error: syntax error, unexpected INHERIT, at (string):1:12\n"
<infinisil> >> inherit (pkgs) x
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> error: attribute 'x' missing, at (string):15:42
<infinisil> >> inherit x
<{^_^}> Inherits need a scope
<infinisil> There we go
<gchristensen> >> inherit ({builtins = null; }) builtins
<{^_^}> Did assign
<gchristensen> >> builtins.map
<{^_^}> <PRIMOP>
<gchristensen> nice
<infinisil> :)
<infinisil> >> ${"x"} = 10
<{^_^}> Assignments to dynamic keys are disallowed
<infinisil> >> x.${"x"} = 10
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> error: attribute 'x' missing, at (string):14:42
<infinisil> >> x = {}
<{^_^}> Did assign
<infinisil> >> x.${"x"} = 10
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> { x = 10; }
<gchristensen> > ${null} = builtins.map
<{^_^}> error: syntax error, unexpected DOLLAR_CURLY, at (string):193:1
<gchristensen> hrm
<infinisil> (>>)
<infinisil> >> ${null} = builtins.map
<{^_^}> Assignments to dynamic keys are disallowed
<infinisil> Also, if you want to allow overriding variables, you can do this:
<infinisil> >> x = self.changeablevalue + 1
<{^_^}> Did assign
<infinisil> >> changeablevalue = 10
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> 11
<infinisil> Whereas:
<infinisil> >> x = changeablevalue + 1
<{^_^}> Did assign
<infinisil> >> changeablevalue = 20
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> 11
<infinisil> >> x = 2
<{^_^}> Did assign
<infinisil> >> x
<{^_^}> 2
<gchristensen> >> self.builtins = []
<{^_^}> Did assign
<gchristensen> >> builtins.map
<{^_^}> <PRIMOP>
<gchristensen> >>self.${null} = "hi"
<gchristensen> >> self.${null} = "hi"
<{^_^}> Did assign
<gchristensen> >> self
<{^_^}> { __unfix__ = <LAMBDA>; attrs = <CODE>; builtins = <CODE>; changeablevalue = 20; deepEval = <CODE>; s = <CODE>; self = { __unfix__ = <LAMBDA>; attrs = <CODE>; builtins = <CODE>; changeablevalue = 20; deepEval = <CODE>; s = <CODE>; self = <CYCLE>; x = 2; y = 20; z = 30; }; x = 2; y = 20; z = 30; }
<infinisil> Ah yes, good point, you can view the environment with self :O
<infinisil> >> self = 1
<{^_^}> Did assign
<infinisil> >> self.self
<{^_^}> error: value is an integer while a set was expected, at (string):18:1
<infinisil> >> self
<{^_^}> 1
<infinisil> >> 10 + self
<{^_^}> 11
<infinisil> Hum..
<gchristensen> >> { type = "derivation"; toString = "lolhi"; }
<{^_^}> { toString = "lolhi"; type = "derivation"; }
<gchristensen> >> toString { type = "derivation"; toString = "lolhi"; }
* gchristensen taps the mic
<infinisil> (currently not running, hold on a minute)
<infinisil> >> self
<{^_^}> 1
<infinisil> gchristensen: go for it
<infinisil> >> self
<{^_^}> { __unfix__ = <LAMBDA>; attrs = <CODE>; builtins = <CODE>; changeablevalue = 20; deepEval = <CODE>; extend = <CODE>; s = <CODE>; self = 1; x = 2; y = 20; z = 30; }
<infinisil> >> self.self
<{^_^}> 1
<gchristensen> >> toString { type = "derivation"; toString = "lolhi"; }
<{^_^}> error: cannot coerce a set to a string, at (string):19:1
<infinisil> >> assert false; 1
<{^_^}> error: assertion failed at (string):19:1
<infinisil> >> builtins.trace "hello" "hello"
<{^_^}> "hello"
<infinisil> >> builtins.trace "hello" "he"
<{^_^}> "he"
<gchristensen> >> { outPath = "foo-bar"; }
<{^_^}> { outPath = "foo-bar"; }
<gchristensen> >> { type = "derivation"; outPath = "foo-bar"; }
<{^_^}> { outPath = "foo-bar"; type = "derivation"; }
<gchristensen> >> >> toString { type = "derivation"; outPath = "foo-bar"; }
<{^_^}> error: NixParseFailure "error: syntax error, unexpected '>', at (string):1:12\n"
<gchristensen> >> toString { type = "derivation"; outPath = "foo-bar"; }
<{^_^}> "foo-bar"
<gchristensen> >> toString { outPath = "foo-bar"; }
<{^_^}> "foo-bar"
<infinisil> Heh neat
<infinisil> >> "${{outPath = "hi"}}"
<{^_^}> error: NixParseFailure "error: syntax error, unexpected '}', expecting ';', at (string):1:30\n"
<infinisil> >> "${{outPath = "hi";}}"
<{^_^}> "hi"
<infinisil> >> "${let {body.outPath = "hi";}}"
<{^_^}> "hi"
<infinisil> >> inherit (pkgs) hello
<{^_^}> Did assign
<infinisil> >> hello.name
<{^_^}> "hello-2.10"
<infinisil> > hello.name
<{^_^}> "hello-2.10"
<infinisil> > hello.name
<{^_^}> "hello-2.10"
<infinisil> >> hello.name
<{^_^}> "hello-2.10"
<infinisil> > :v weird1
<{^_^}> weird1 = (1.0 * 1) * 1
<infinisil> >> let rec { body = 10; }
<{^_^}> error: NixParseFailure "error: syntax error, unexpected REC, at (string):1:16\n"
<infinisil> >> let (rec { body = 10; })
<{^_^}> error: NixParseFailure "error: syntax error, unexpected '(', at (string):1:16\n"
<infinisil> >> quotes.infinisil = [ "hello" ]
<{^_^}> Did assign
<infinisil> >> quotes.infinisil = quotes.infinisil ++ [ "what" ]
<{^_^}> Did assign
<infinisil> >> deepEval quotes
<{^_^}> { infinisil = [ "hello" "what" ]; }
<infinisil> Something really cool about this new nix eval is that it can kill old definitions if they're not needed anymore, but keeps them alive otherwise
<infinisil> So if I do
<infinisil> >> x = 1
<{^_^}> Did assign
<infinisil> >> y = x + 2
<{^_^}> Did assign
<infinisil> >> x = 0
<{^_^}> Did assign
<infinisil> >> y
<{^_^}> 3
<infinisil> And it keeps the x = 1, but if I do
<infinisil> >> y = 0
<{^_^}> Did assign
<infinisil> It can remove the definition for x = 1 out of its state
<infinisil> Can also use this later to implement the ability to remove assignments, because it knows the dependencies between them
<infinisil> >> self
<{^_^}> { __unfix__ = <LAMBDA>; attrs = <CODE>; builtins = <CODE>; changeablevalue = 20; deepEval = <CODE>; extend = <CODE>; hello = <CODE>; quotes = <CODE>; s = <CODE>; self = 1; x = 0; y = 0; z = 30; }
<infinisil> >> self.__unfix__
<{^_^}> <LAMBDA>
<infinisil> >> self.__unfix__ 10
<{^_^}> { attrs = <CODE>; builtins = <CODE>; changeablevalue = 20; deepEval = <CODE>; hello = <CODE>; quotes = <CODE>; s = <CODE>; self = 1; x = 0; y = 0; z = 30; }
<infinisil> >> ${"x"} + ${"y"}
<{^_^}> error: NixParseFailure "error: syntax error, unexpected DOLLAR_CURLY, at (string):1:12\n"
<infinisil> >> self.${"x"} + self.${"y"}
<{^_^}> 0
<infinisil> >> allUp = lib.mapAttrs (n: v: v + 1) self
<{^_^}> Did assign
<infinisil> >> allUp.z
<{^_^}> 31
<infinisil> >> z = 1
<{^_^}> Did assign
<infinisil> >> allUp.z
<{^_^}> 2