gchristensen changed the topic of #nixos-chat to: NixOS but much less topical || https://logs.nix.samueldr.com/nixos-chat
gchristensen has quit [*.net *.split]
ma27 has quit [*.net *.split]
biopandemic has quit [*.net *.split]
ldlework has quit [*.net *.split]
NinjaTrappeur has quit [*.net *.split]
ldlework has joined #nixos-chat
gchristensen has joined #nixos-chat
ma27 has joined #nixos-chat
biopandemic has joined #nixos-chat
NinjaTrappeur has joined #nixos-chat
Ericson2314 has quit [Ping timeout: 260 seconds]
kisik21 has quit [Ping timeout: 272 seconds]
lassulus_ has joined #nixos-chat
lassulus has quit [Ping timeout: 256 seconds]
lassulus_ is now known as lassulus
<ldlework> infinisil: did your znc changes make it into unstable yet
<ldlework> or do you have an overlay that enables it?
<samueldr> it isn't in unstable yet, and only two weeks from the branch-off date ;)
<infinisil> Ahhh
<infinisil> Need to finish it
<infinisil> I'll have my last exam soon, after that I'll have more time, and hopefully enough motivation to finish it
<ldlework> ok hopefully I don't need to mess with my server because I forgot what I did to get that to work for nixops heh
<ldlework> i removed something and now it wont deploy because your attribute doesn't exist heh
<ldlework> oops
Drakonis has joined #nixos-chat
Ericson2314 has joined #nixos-chat
disasm has joined #nixos-chat
pie__ has quit [Ping timeout: 272 seconds]
Drakonis has quit [Remote host closed the connection]
jD91mZM2 has joined #nixos-chat
tertle||eltret has quit [Quit: Connection closed for inactivity]
disasm has quit [Quit: WeeChat 2.0]
disasm has joined #nixos-chat
Lisanna has quit [Quit: Lisanna]
Ericson2314 has quit [Remote host closed the connection]
<jD91mZM2> OH FUK! We just got a stack overflow with my recursive descent parser, peeps
<jD91mZM2> Oh, unless it's just stuck in an infinite loop. Would make more sense. False alarm... hopefully
<jD91mZM2> Yep, false alarm! All good :D
* jD91mZM2 looking at the code he wrote yesterday: "Dear god, who wrote this crap"
<jD91mZM2> Woah! TODO list finally done! Now I need to try parsing my own nixos config and see how it goes
<ekleog> one nice thing to do for tests is write a basic program that outputs the AST passed to it, and try to parse->output->parse, and check it's parsed twice the same thing (preferably, using another parser than the first one, but it's enough to discover at least some errors)
<ekleog> you can run it on all nixpkgs, then, I've uncovered at least one bug in hnix by doing so :°
Lisanna has joined #nixos-chat
<MichaelRaskin> nix-instantiate --parse is probably a suitable normaliser
<jD91mZM2> ekleog: Yep, currently writing a dump-ast example
<jD91mZM2> I don't currently have a way to print out the AST to valid nix but I'll make another example that does that
<jD91mZM2> Darn, first try at running it against my own config was a failure
<jD91mZM2> I forgot you could do thing."some text".other_thing
<jD91mZM2> Oh, so you can make idents with strings... but only inside sets. That's kinda weird.
<jD91mZM2> Second attempt, success! Don't know if it's valid AST, but it does parse!
<infinisil> jD91mZM2: do you have dynamic attrnames working?
<jD91mZM2> infinisil: Oh god... what are those
<infinisil> > { "${if true then "hi" else "foo"}" = 1; }
<{^_^}> { hi = 1; }
<infinisil> jD91mZM2: those ^^
<ekleog> running the parser on all of nixpkgs uncovers various stuff, like the fun priority of { foo = 0; }.bar or 1 + 1 :D
<ekleog> > { foo = 0; }.bar or 1 + 1
<{^_^}> 2
<ekleog> > { foo = 0; }.foo or 1 + 1
<{^_^}> 1
<ekleog> actually
<jD91mZM2> WELP, there goes, `or` is not a thing yet
<infinisil> Ah right, forgot about or too :P
<ekleog> (something hnix got wrong at first, btw :°)
<ekleog> that said apart from dynamic attrnames and `or` syntax, I'm not sure I could think of other “weird stuff” in nix syntax
<jD91mZM2> Are dynamic attrnames limited to interpolation?
<ekleog> > "a" + "b"
<{^_^}> "ab"
<ekleog> > { "a" + "b" = 1; }
<{^_^}> error: syntax error, unexpected '+', expecting '.' or '=', at (string):166:7
<ekleog> yes
<jD91mZM2> Good, then that should be relatively easy hopefully
<infinisil> > { ${"a" + "b"} = 10; }
<{^_^}> { ab = 10; }
<ekleog> well, that's interpolation :)
<ekleog> (except it's not enclosed by "", but that's like foo."b${"a"}r" and foo.${"bar"})
<jD91mZM2> Oh, that's valid syntax too
<jD91mZM2> ffffFFFFFFFFFFF
<ekleog> yeah, nix syntax is great :D
<ekleog> all hail nix syntax
<infinisil> > fun = n: { ${n} = 1; ${n} = 2; }
<{^_^}> fun defined
<infinisil> Quiz: call function fun with an argument such that it doesn't throw an error
<jD91mZM2> > fun hello
<{^_^}> value is a set while a string was expected
<jD91mZM2> > fun "hello"
<{^_^}> dynamic attribute 'hello' at (string):68:23 already defined at (string):68:13
<jD91mZM2> > fun "${n + 1}"
<{^_^}> undefined variable 'n' at (string):166:8
<ekleog> infinisil: oh that looks fun :D
<infinisil> :P
<ekleog> (I guess builtins.exec is off-limits?)
<infinisil> Yup
<ekleog> > fun (toString builtins.currentTime)
<{^_^}> dynamic attribute '"1534238231"' at (string):68:23 already defined at (string):68:13
<ekleog> huh :(
<infinisil> Builtins.currentTime is constant during the whole evaluation
<jD91mZM2> x = 3
<infinisil> Want me to reveal the solution?
<jD91mZM2> > fun (x = x + 1)
<{^_^}> error: syntax error, unexpected '=', expecting ')', at (string):166:8
<jD91mZM2> yes
<ekleog> > fun (builtins.getEnv "RANDOM")
<{^_^}> dynamic attribute '""' at (string):68:23 already defined at (string):68:13
<ekleog> > fun (toString builtins.deepSeq)
<{^_^}> cannot coerce a built-in function to a string, at (string):166:6
<ekleog> > fun (builtins.readFile /dev/urandom)
<{^_^}> access to path '/dev/urandom' is forbidden in restricted mode
<infinisil> ekleog: want the solution?
<ekleog> hmm I'd take a hint: is builtins the right direction?
<MichaelRaskin> > fun ( n or "12")
<{^_^}> undefined variable 'n' at (string):166:7
<infinisil> Nope, the solution is actually very simple
<MichaelRaskin> > fun ${n}
<{^_^}> error: syntax error, unexpected DOLLAR_CURLY, expecting ')', at (string):166:5
<MichaelRaskin> fun "${n}"
<MichaelRaskin> > fun "${n or 3}"
<{^_^}> undefined variable 'n' at (string):166:8
<MichaelRaskin> > fun "a.b"
<{^_^}> dynamic attribute '"a.b"' at (string):68:23 already defined at (string):68:13
<MichaelRaskin> > fun "a"."b
<{^_^}> error: syntax error, unexpected $end, expecting '"', at (string):166:10
<MichaelRaskin> > fun "a"."b"
<{^_^}> value is a string while a set was expected, at (string):166:5
<infinisil> The solution requires knowing something about nix that's rather unknown
<MichaelRaskin> > fun (x: x+1)
<{^_^}> value is a function while a string was expected
<ekleog> > fun "a = b"
<{^_^}> dynamic attribute '"a = b"' at (string):68:23 already defined at (string):68:13
<ekleog> were the set declared `rec` I may have more ideas, but here it's hard x)
<ekleog> +had
<ekleog> > fun null
<{^_^}> { }
<ekleog> AH
<ekleog> BUT WHY?
<infinisil> Bingo!
<ekleog> > "${null}"
<{^_^}> cannot coerce null to a string, at (string):166:2
<infinisil> > { ${null} = 1; }
<{^_^}> { }
<jD91mZM2> > { ${true} = 1; }
<{^_^}> value is a boolean while a string was expected
<infinisil> ekleog++
<ekleog> > fun2 = x: { "${x}" = 1; "${x}" = 2; }
<{^_^}> ekleog's karma got increased to 2
<{^_^}> fun2 defined
<jD91mZM2> kill me now
<ekleog> > fun2 null
<{^_^}> cannot coerce null to a string, at (string):69:15
<ekleog> BUT
<ekleog> so { ${a} = b; } and { "${a}" = b; } are different ._.
<infinisil> Apparently lol
<ekleog> { foo = 1; }.${null}
<ekleog> > { foo = 1; }.${null}
<{^_^}> value is null while a string was expected
<ekleog> > { foo = 1; }."${null}"
<{^_^}> cannot coerce null to a string, at (string):167:15
<ekleog> at least this one is sane :)
* jD91mZM2 deletes rust-nix (jk)
<ekleog> heh
<ekleog> this one looks like something that won't have to be dealt with at parser level but at evaluator level, at least
<MichaelRaskin> Let me guess: NixOS module system critically depends on this behaviour?
<ekleog> just have to make sure you distinguish between the parsing of the two ${x} and "${x}" parts
<infinisil> MichaelRaskin: most likely :P
<ekleog> the world is broken and there's nothing we can do about it :((
<MichaelRaskin> Abandon NixOS and use only the sanest parts of Nix!
<ekleog> yeah, I've started to do that
<ekleog> even got a sane module system working
<MichaelRaskin> You don't even need a module system
<infinisil> Meaning? How does it work?
<ekleog> but somehow I can't get udev to detect the network adapter of the VM I'm starting it in, so I've got to manually modprobe the adapter x)
<MichaelRaskin> You just need a sane system for package overrides…
<MichaelRaskin> We want it anyway…
<ekleog> (the test-* are hard-coded hacks for testing)
<ekleog> the idea being that each module states what other kinds of modules it can extend, and doesn't hardcode its dependencies
<MichaelRaskin> In my system I just try to treat the system composition as a normal overridable package set
<MichaelRaskin> But good override logic for package sets is still complicated…
<infinisil> Hmm
<MichaelRaskin> (but even in Nixpkgs we suffer from imperfections of available override approaches…)
<ekleog> (currently the extends syntax is pointlessly complex, I've got to refactor this, but this udev issue has made me ragequit and I haven't managed to find the motivation to change it again)
<ekleog> basically started from a “what if I want to remove systemd” reasoning, here it'd be enough to just set init = systemd or init = runit or whatever instead of using core-system :)
<ekleog> MichaelRaskin: I don't really get it, how do you handle that?
<MichaelRaskin> Well, in Nixpkgs we have ImageMagick that can be built with different subsets of image libraries
<MichaelRaskin> In a system you have system path that can be built with different sets of installed packages
<MichaelRaskin> I don't really want these to be different
<MichaelRaskin> And I like what we have for package sets more than the module systems
<MichaelRaskin> But still, there are problems…
<ekleog> How do you handle eg. configuring your init system to run your webserver, and have the webserver log to your logger?
<ekleog> (basically, 1-to-n and n-to-1 dependencies, the two cases I came up with when designing my “module” system à-la GuixSD)
<MichaelRaskin> Oh well, I actually want the Nix part just to give me scripts and let the stage-3 in Lisp launch what needs launching. And I want logs to go to plain files by redirecting stderr whenever possible. but in general, n-to-1 would be to override the logging services with whatever settings need to be changed, then it gets used as a parameter by whatever services default to using the logger service.
<MichaelRaskin> (And can be passed by overriding to services that do not use it by default but can use it)
<ekleog> just so that I can picture it better in my head: for iptables, let's say I have module M that, when enabled, should open a port in the firewall, how would that look like for you? (iow, the 1-to-n case)
<MichaelRaskin> This is actually what I do not want
<MichaelRaskin> I.e. I would prefer iptables.override { rulesFromServices = [ M ]; }
<ekleog> also, for the n-to-1 case, if I have a logging system that accepts logs from /run/${user-defined-value}.sock, then how do you handle propagating that user-defined-value back to all services that depend on it?
<ekleog> hmm… but at least for init you need to have something like that, don't you? or for nginx / apache / etc. for websites
<MichaelRaskin> Well, how do we do a global override of libX11 = null; ?
<MichaelRaskin> (Answer: painfully)
<MichaelRaskin> (But my system definition is smaller than Nixpkgs, so it is not a problem yet; and a lot of logic is pushed to Lisp code anyway)
<ekleog> hmm'k :) I think I'll go back to working on my system (when I'm motivated enough to tackle eudev again) with possibility to hotswap any component in/out with a custom fixpoint, then :)
<ekleog> thank you for this discussion!
<MichaelRaskin> I want to hotswap many things in runtime, so I want system build to produce a set of bricks, not a monolith
<ekleog> hmm good point
<ekleog> but if that requires a custom daemon running to hold everything together… :/
<MichaelRaskin> Well, having a custom daemon was among the goals
<MichaelRaskin> I mean, in a location I want to reconfigure the network, the displays, the fetcher daemons…
<MichaelRaskin> I want to write this all in a language I don't hate, and suitable for weird policies beyond the optimum point of shell scripting.
<ekleog> “in a location”?
<MichaelRaskin> It's a laptop
<ekleog> ooh, a physical location
<ekleog> hmm… I do agree with you that nixos-rebuild requiring to restart every daemon that has changed is painful
<MichaelRaskin> I am OK with restarting every daemon
<ekleog> so the issue is “in a language I don't hate”?
<MichaelRaskin> I am not OK with systemd failing the basic logic of logging, limiting how I am allowed or not allowed to spawn multiple X servers, etc.
<MichaelRaskin> Also, my concerns are cross-cutting
<ekleog> yeah well forcing systemd is stupid, but that sounds orthogonal to the need for a custom daemon holding everything together to me :)
<MichaelRaskin> nixos-rebuild is not supposed to run xrandr
<ekleog> (typically, I've defined an interface between services and the init service, so I can have a runit running as pid1, then another runit as pid2 that's run by pid1, and then have some services under runit-pid1 and some services under runit-pid2)
<ekleog> xrandr?
<MichaelRaskin> Well, I want a lot of small things. The real logic I want from sudo is orthogonal to what is normally offered
<ekleog> (it doesn't need to be all runit's btw, can be a runit spawned by openrc, or whatever -- just that actually I've implemented only the runit backend)
<ekleog> s/actually/currently/
<MichaelRaskin> Well, in different locations I might have different monitor sets — and different desired brightness
<MichaelRaskin> I want custom daemon because I will need to implement a lot of small logical pieces anyway
<ekleog> but… couldn't that be implemented as a small standalone daemon?
<MichaelRaskin> A ton of them
<MichaelRaskin> One for true sudo logic
<MichaelRaskin> One to manage Firefox etc. isolation
* ekleog rather have a ton of standalone daemons than a single big daemon, makes daemon failure less painful
<MichaelRaskin> Meh, that's Lisp.
<MichaelRaskin> Failures are either clean crash or ignorable
<MichaelRaskin> You don't have the memory walks causing random actions
<ekleog> even clean crash is an issue when all your computer handling is in there… or not?
<MichaelRaskin> Nope
<MichaelRaskin> Main daemon crashes, it is respawned, big deal
<ekleog> oh, it's stateless?
<MichaelRaskin> There is a little bit of state (when I grab random high UIDs, I want to remember which user account has access to what transient UIDs).
<MichaelRaskin> Stored on a tmpfs with sqlite
<MichaelRaskin> I probably should do better locking around sqlite calls from threads, as it sometimes gets unhappy.
<MichaelRaskin> But if sqlite gets unhappy, I just crash the daemon and everything is fine again
<ekleog> hmm'k :)
<ekleog> so next question because I'm curious about your setup: what do you call “true sudo logic”? 😇
<MichaelRaskin> Erlang people are right: if you have any doubts, crash it and let it recover
<MichaelRaskin> Well, what is the true condition when you want a person to ask for reboot?
<ekleog> policykit? :3
<MichaelRaskin> a) they know root password, b) they know one of the passwords from accounts in sudoers c) they are sitting at the computer, goddamn it
<MichaelRaskin> Policykit is getting all that wrong
<MichaelRaskin> If I am logged in to my notebook but issue the command via SSH, it is a different situation
<MichaelRaskin> And I don't want an abomination to take over all the sessions to answer the question «is the request from a user near the laptop»
<MichaelRaskin> I want to use that nice invention called «VTs»
<ekleog> so if I understand correctly, your daemon checks that you are on a local VT before granting you the right to reboot?
<ekleog> (yeah, polkit was a bit of a taunt 😇)
<MichaelRaskin> Nope. It shows me a confirmation dialog on VT63.
<ekleog> hmm… vt63? what did you bind on it?
<MichaelRaskin> Nothing. It switches to tty63, locks it, starts fbterm, shows the request, waits for reaction or lack thereof, switches back (unlocking the vt switch)
<ekleog> oh 'k :)
<ekleog> all your ideas sound really good, I just find it a bit sad that they come in an all-or-nothing package ^^
<MichaelRaskin> Well, not completely all-or-nothing
<MichaelRaskin> As the daemon is ready to be force-crashed, it is also _not_ assuming it is the only daemon managing the system (unlike, well, some other system manangement approaches)
<MichaelRaskin> So it is not hard to have your normal system, and also run this daemon to invoke only for requests you want to pass it
<ekleog> hmm, but then the daemon is ~equivalent to a setuid wrapper around some helpers? if it's only reacting to requests you explicitly pass it
<MichaelRaskin> The daemon is supposed to only reqct to requests, yes
* ekleog got to go, thank you for the discussion!
<MichaelRaskin> Bye
<jD91mZM2> Finally done with dynamic attributes
<infinisil> > { foo = 10; } ? foo
<{^_^}> true
<infinisil> jD91mZM2: Got this? ^^
<jD91mZM2> infinisil: Darn, no I haven't
<jD91mZM2> btw renaming rust-nix to rnix
<jD91mZM2> It looks nicer when using as a library. extern crate rust_nix; vs extern crate rnix;
<jD91mZM2> Nix patterns should use `or` and not ?, in that case btw
<jD91mZM2> makes more sense
<jD91mZM2> infinisil: Implemented that and `or`
<jD91mZM2> I pretty much just formatted my /etc/nixos/configuration.nix using rnix :D
<jD91mZM2> Not sure all comments are intact, but I'm honestly surprised at how many were
disasm has quit [Ping timeout: 272 seconds]
<jD91mZM2> Currently trying to run nixpkgs. Main file has this:
<jD91mZM2> inherit (trivial) id const concat or and boolToString mergeAttrs
<jD91mZM2> flip mapNullable inNixShell min max importJSON warn info
<jD91mZM2> nixpkgsVersion mod compare splitByAndCompare
<jD91mZM2> functionArgs setFunctionArgs isFunction;
<jD91mZM2> That `or` is very weird
<jD91mZM2> Since it's a keyword... Or should be
<jD91mZM2> Seems like you can assign and use keywords as variables in nix????
<andi-> yes, IIRC you can also do true = false
<andi-> > true = false
<{^_^}> true defined
<jD91mZM2> > true
<{^_^}> false
<jD91mZM2> > or = 3;
<{^_^}> error: syntax error, unexpected ';', at (string):97:9
<jD91mZM2> > or = 3
<{^_^}> or defined
<jD91mZM2> > or
<andi-> > true = !true
<{^_^}> error: syntax error, unexpected OR_KW, at (string):169:1
<{^_^}> true defined
<jD91mZM2> > or
<{^_^}> error: syntax error, unexpected OR_KW, at (string):169:1
<jD91mZM2> > if = 3
<{^_^}> error: syntax error, unexpected IF, at (string):72:2
<jD91mZM2> ::::|||||
<andi-> > 1 mod 1
<{^_^}> attempt to call something which is not a function but an integer, at (string):169:1
<andi-> > mod
<{^_^}> undefined variable 'mod' at (string):169:1
<gchristensen> note you can also PM the bot to find interesting stuff :)
<jD91mZM2> Sharing is caring
<jD91mZM2> He's sharing all the weird things about nix that'll ruin my parser
<MichaelRaskin> rnix? Last when I checked what sounds yaks produce, the best transcription was ~ "RN!"
<jD91mZM2> I renamed rust-nix
<MichaelRaskin> So, yaks approve! And hope to be well-shaved
biopandemic has quit [Ping timeout: 256 seconds]
pie_ has joined #nixos-chat
<jD91mZM2> Something cool you can do with rnix: https://i.imgur.com/VDM0ogP.png
<gchristensen> hmm that works though
<gchristensen> nix-repl> { or = 123; }
<gchristensen> { or = 123; }
<jD91mZM2> Oh yeah, we just discussed that, that's something I gotta fix
<jD91mZM2> Point is the span informatin
<jD91mZM2> s/informatin/information
<gchristensen> aah
<jD91mZM2> > { if = 5; }
<{^_^}> error: syntax error, unexpected IF, at (string):169:3
<jD91mZM2> inconsitencies :D
<jD91mZM2> > { assert = 4; }
<{^_^}> error: syntax error, unexpected ASSERT, at (string):169:3
<gchristensen> nix-repl> { "if" = "hi"; }
<gchristensen> { if = "hi"; }
<jD91mZM2> That works in mine too :D
<gchristensen> good :)
<jD91mZM2> Implemented dynamic attributes earlier today. Was a pain :P
<gchristensen> > let foo = "hi"; in { ${foo} = "there"; }
<{^_^}> { hi = "there"; }
<gchristensen> like that?
<jD91mZM2> Yep
<jD91mZM2> Obviously it doesn't need to do any variable lookup though - it's just a parser
<gchristensen> I don't like that syntax, I think it was a mistake to not put it in quotes.
<jD91mZM2> Definitely true
<jD91mZM2> Although, even in quotes they are just uGH
<gchristensen> they're important to support variables in attrs
<jD91mZM2> I don't personally see why that needs to be a thing
<MichaelRaskin> I think builtins.listToAttrs have been enough for a long time
<gchristensen> well sometimes you need a dynamic key and it just is
<jD91mZM2> Which keywords can be assigned to variables in nix, and which can't?
<gchristensen> w/out quotes?
<jD91mZM2> Yeah
<jD91mZM2> > { or = 3; if = 2; assert = 1; }
<{^_^}> error: syntax error, unexpected IF, at (string):169:11
<MichaelRaskin> Joys of separate lexer
<gchristensen> > { assert = 1; }
<{^_^}> error: syntax error, unexpected ASSERT, at (string):169:3
<clever> > { "assert" = 1; }
<{^_^}> { assert = 1; }
<clever> > ({ "assert" = 1; }).assert
<{^_^}> error: syntax error, unexpected ASSERT, expecting ID or OR_KW or DOLLAR_CURLY or '"', at (string):169:21
<clever> > ({ "assert" = 1; })."assert"
<{^_^}> 1
<clever> > { "assert" = 1; "a.b" = 2; }
<{^_^}> { "a.b" = 2; assert = 1; }
<clever> gchristensen: good luck using any attribute on this set without problems! :D
<gchristensen> lol
<gchristensen> { "" = 1; }.""
<gchristensen> > { "" = 1; }.""
<{^_^}> 1
<clever> :O
* gchristensen shrugs
<clever> i also recently saw warnings about using HashMap in haskell, and that an attacker can use partial hash collisions to make the performance worse
<samueldr> and don't forget about `${null}` :)
<samueldr> > {${null} = 1;}
<clever> and because aeson uses that for the keys in the json, an attacker can craft json that takes a crap-ton of cpu to parse
<{^_^}> { }
<MichaelRaskin> Horrible question: imagine a sensible language extension where { assert = …; } is useful, makes sense and is not the same as { "assert"=…; }
<clever> gchristensen: but nix doesnt suffer from this, because all keys in a set are turned into ints, and the id is just an auto-increment in a global variable
<gchristensen> nice
<clever> the only cost is a one-time (ish) lookup of the key in the global map
<clever> and then all keys are basically ints
<gchristensen> iirc that is an ancient vulnerability of Perl's
<LnL> samueldr: null is great to avoid rebuilds :)
<clever> , sColumn(symbols.create("column"))
<samueldr> and then there's this
<samueldr> > rec { ${null} = 1; null = "2"; }
<{^_^}> { "2" = 1; null = "2"; }
<clever> , sName(symbols.create("name"))
<clever> gchristensen: some of the keys in a set are pre-created very early on, and the int version is saved in a field on the class
<clever> gchristensen: so you can then just read the sName key in a set, and can skip finding out what int is behind "name"
<samueldr> (I mean, it all makes sense, but it could be surprising still)
<gchristensen> clever do you know about __overrides?
<clever> , sOverrides(symbols.create("__overrides"))
<clever> gchristensen: dont think so
<gchristensen> found that the other day, very very interesting
<clever> gchristensen: oh, wow
<gchristensen> not to be used I think :P
<clever> that solves all the noobs trying to override version in a derivation!
<LnL> yeah, I had to stare at that for a wile :p
<gchristensen> > let overrides = { a = 2; };in (rec {__overrides = overrides;x = a;a = 1;}).x
<{^_^}> 2
<clever> dont tell anybody that exists, lol
<gchristensen> :P
<jD91mZM2> Good thing that isn't something I need to change in the parser or I would be so mad
<LnL> do you handle let { }
<jD91mZM2> Yep, infinisil told me about it
<LnL> > let { x = 1; body = x; }
<{^_^}> 1
<gchristensen> its just a parser, so no need I think
<infinisil> Why the hell does __overrides exist oh my god
<andi-> there are some scary features burried :D
<jD91mZM2> > { in = 3; }
<{^_^}> error: syntax error, unexpected IN, at (string):169:3
<jD91mZM2> So almost all tokens fail except for "or"
<LnL> gchristensen: let x = 1; in x parses differently, you'd epxect the braces there to be invalid syntax
<gchristensen> oh I see
<infinisil> > rec { __overrides = {}; }
<{^_^}> { __overrides = { }; }
<infinisil> > (rec { __overrides = {}; x = a; a = 1; }) // { __overrides = { a = 2; }; }
<{^_^}> { __overrides = <CODE>; a = <CODE>; x = <CODE>; }
<infinisil> > ((rec { __overrides = {}; x = a; a = 1; }) // { __overrides = { a = 2; }; }).x
<{^_^}> 1
<gchristensen> this hurts
<clever> dang
<infinisil> Yeah :(
<clever> so it cant change .version in derivations
pie_ has quit [Ping timeout: 272 seconds]
biopandemic has joined #nixos-chat
pie_ has joined #nixos-chat
Drakonis has joined #nixos-chat
<andi-> I just wrote `inherit foo` in python... Nix is a disease m(
<jD91mZM2> If Nix is a disease I don't want a cure <3
<andi-> same :)
<gchristensen> some JSON I tried to write just now: "facility": [ "ewr1" "iad1" "atl1" "any" ],
<andi-> I do the same..
<sphalerite> pro tip: Write all your JSON in nix, then nix-instantiate --eval --json it :D
<sphalerite> or use Dhall
<gchristensen> :)
<jD91mZM2> Oof, trying to parse nixpkgs reveals lots of errors
<infinisil> jD91mZM2: such as?
<gchristensen> nixpkgs has lots of fascinating syntax
<jD91mZM2> Mainly small stuff first, like _name not being a valid identifier (because I forgot the _)
<jD91mZM2> But then also a small parsing bug with patterns that only have one element
<LnL> ah yeah, non string interpolation
<LnL> vim-nix used to freak out about that for a while
<jD91mZM2> Hmm if I'm not mistaken all I need to do is return the inner AST?
<jD91mZM2> ${attr} == attr?
<jD91mZM2> Oh, no, never mind
<jD91mZM2> Ah, most of this I already implemented, it's just that I need to support it in ? expressions
<jD91mZM2> Here we go, our first proper unimplemented: https://gist.github.com/82a2ac658d5d6148ee5c09b2cf2fc1d8
<jD91mZM2> What is the -> syntax?
<gchristensen> it is the logical implicationoperator
<jD91mZM2> Which means?
<jD91mZM2> So a -> b means "if not a then b"
<jD91mZM2> nvm, "if a then b"
* jD91mZM2 is confused about why this is a thing
<jD91mZM2> But why not `!bootable || bootImage != ""`
<gchristensen> because assert bootable -> bootImage != ""; is much more clear
<jD91mZM2> we might have to disagree on that one
<jD91mZM2> It's only more clear if you already know the syntax
<jD91mZM2> Most people coming from non-functional languages don't know ->
<jD91mZM2> or assume it's some kinda of pointer
Ericson2314 has joined #nixos-chat
<gchristensen> that is okay, it is a functional language
<jD91mZM2> Am I correct in that it has the same presedence as ||? Seems like it
<jD91mZM2> true || true -> false is true, meanwhile true -> false || true is false
<jD91mZM2> actually no never mind me my logic does not make sense
<gchristensen> `!bootable || bootImage != ""` requires I write out a truth table
pie_ has quit [Remote host closed the connection]
pie_ has joined #nixos-chat
<samueldr> the precedence is documented in the manual
<samueldr> https://nixos.org/nix/manual/#table-operators "in order of precedence (from strongest to weakest binding)."
<samueldr> (though I'm kinda assuming you know and I'm kinda not-nice for RTFMing)
<jD91mZM2> I didn't :)
<jD91mZM2> I've just been experimenting in the repl lol
<samueldr> that table is great for associativity too
<gchristensen> for a newbie I think it is really easy to see `assert bootable -> bootImage != ""` and guess from context that it means if bootabl is true, require this other thing to be true
<gchristensen> without taking the time to learn what it actually means
__monty__ has joined #nixos-chat
<jD91mZM2> samueldr: That just showed me a bug :D
<samueldr> :)
<jD91mZM2> -function arg, in my parser would be (-function) arg
pie_ has quit [Ping timeout: 240 seconds]
<jD91mZM2> gchristensen: Sorry for not replying earlier btw, didn't wanna get into a discussion. I'm usually for having syntax be as simple and least fancy as possible, but I do get your argument about it being cleaner
<jD91mZM2> rnix just scanned 22 different nixpkgs files and after some tweaking, all of them work
<jD91mZM2> (It stopped because it didn't find any import statements, I haven't implemented a search in the full AST yet)
* joepie91 sings "SGX is dead, SGX is dead, SGX is dead..."
<jD91mZM2> So. Many. Processor. Bugs. This. Year.
<simpson> jD91mZM2: Winter arrived a few years ago.
<jD91mZM2> ?
<simpson> Our ability to find bugs in systems has outstripped our engineering ability to build bug-free systems.
<jD91mZM2> That's fun
<joepie91> jD91mZM2: even better than regular processor bugs
<joepie91> SGX is Intel's 'secure enclave'
<joepie91> y'know, the supposedly user-tamperproof thing
<joepie91> lol
<Drakonis> which isn't used by linux btw
<jD91mZM2> What CPUs do you guys prefer?
<Drakonis> ryzen i guess
<joepie91> I'm becoming increasingly tempted to answer 'stone tablet' to that question
<simpson> I've been a steady purchaser of AMD whenever I can, but that's mostly only been GPUs. My new desktop is AMD though.
<Drakonis> their CPUs are great now
<Drakonis> took a while but they finally caught up with intel
<andi-> Stone tablet sounds like a great CPU. Perfect power consumption, almost no bugs?
<MichaelRaskin> simpson: I would say that it's more like the ability of CPU manufacturers to lie that they care about security has run out
<joepie91> andi-: dunno, some of them have quite a lot of bugs living under them
<jD91mZM2> samueldr: I just tried an example rnix formatter on my nixos config file, and it worked surprisingly well: https://gist.github.com/1a87c47a5f98650ca5e8b854e91b074d
<simpson> MichaelRaskin: Sure, were it limited to CPUs. The trend I'm talking about has been affecting kernels and userlands too.
<jD91mZM2> I didn't try to preserve whitespace, but that's totally possible as well with all the span information
<gchristensen> pretty good
<gchristensen> https://gist.github.com/jD91mZM2/1a87c47a5f98650ca5e8b854e91b074d#file-foo-diff-L70-L74 isn't a valid transformation, but pretty good
<jD91mZM2> Should be the same thing in this case?
<MichaelRaskin> simpson: I think in software land it doesn't feel like too much change from a normal pendulum
<jD91mZM2> But yeah I just made it treat all interpolated strings as multiline lol
<simpson> MichaelRaskin: Maybe. I see a continued resistance to memory safety, and a continued commitment to avoiding higher-level abstractions and simpler security models.
<gchristensen> jD91mZM2: I think the replacement will create a \n
<jD91mZM2> gchristensen: Oh yeah good point
<MichaelRaskin> simpson: see? business as usual
<gchristensen> simpson: other than division, what do you think about pony?
<jD91mZM2> gchristensen: I should probably have some difference between multiline strings and normal ones in the AST lol
<gchristensen> did I ask you this already?
<gchristensen> jD91mZM2: how does rnix handle a multiline string without any interpolation?
<jD91mZM2> gchristensen: It parses it like nix would - disregards leading whitespace
<simpson> gchristensen: I think you did, and I think I linked you to issues like https://github.com/ponylang/rfcs/pull/28
<{^_^}> ponylang/rfcs#28 (by dckc, 1 year ago, open): FFI taming
<gchristensen> simpson: h yes!
<gchristensen> but on re-emitting it, would it emit a multi-line string, or a "..\n..\n"?
<jD91mZM2> re-emitting?
<gchristensen> what would rnix's nix formatter do
<jD91mZM2> gchristensen: FYI the formatter is just an example and not something I'll actually spend much time on
<jD91mZM2> gchristensen: Currently when you parse a multiline string there's no difference between a normal string and a multiline string
<jD91mZM2> gchristensen: The reason it chose a multiline string here is because it's interpolation - hardcoded to do that in the formatter. This is not correct.
<gchristensen> you said: "But yeah I just made it treat all interpolated strings as multiline lol" so, would it read in foo = ''bar\nbaz\n'' and emit foo = "bar\nbaz\n" or foo = ''bar\nbaz\n''?
<jD91mZM2> Yep.
<gchristensen> which yep?
<jD91mZM2> Oh sorry, I misunderstood
<jD91mZM2> The first one
<gchristensen> gotcha
<gchristensen> thanks :)
<jD91mZM2> I don't even support \n in strings lol. I was so focused on the parser I didn't think of the small things haha
<infinisil> Oh strings! Right, you got a lot of weird escaping to do
<infinisil> ,escape"
<{^_^}> " double quote: \" backslash: \\ bash curly bois: \${} newline: \n tab: \t "
<infinisil> ,escape''
<{^_^}> '' two single quotes: ''' bash curly bois: ''${} newline: ''\n tab: ''\t any character x: ''\x ''
<infinisil> ,escape-special
<{^_^}> A $${foo} will insert the literal string "$${foo}". Use \$${foo} in " strings or ''$${foo} in '' strings to have foo interpolated
<jD91mZM2> OOOH BOOOOI
<sphalerite> curly bois :')
<jD91mZM2> Normal strings have the "any character x" thing btw, not multiline
<jD91mZM2> \x = x
<jD91mZM2> \a = a
<jD91mZM2> etc
<jD91mZM2> But, in multiline strings, \x = \x
<Drakonis> boyes there will be steam breakage soon
<Drakonis> valve will add wine/dosbox support
<sphalerite> nice
<sphalerite> will it really break steam though?
<Drakonis> well, it'll break on nix
<sphalerite> will it?
<Drakonis> because of the way the nix derivation is written
<infinisil> > '' ''\x ''
<{^_^}> "x "
<sphalerite> I mean, I wouldn't be surprised if it did break. But also if it continues working
<infinisil> jD91mZM2: ^
<infinisil> Ohh
<infinisil> I guess the escape'' message can be misinterpreted
<infinisil> The '' at the start and end are supposed to make it look like an actual multiline string, the whole message
<jD91mZM2> infinisil: Ooooh
<Drakonis> i don't think it part of the normal runtime
<jD91mZM2> infinisil: Why is that escape even a thing?
<infinisil> Quiz: How to escape '${ in a multiline string
<jD91mZM2> oh
<jD91mZM2> > '' ''\' ''${} ''
<{^_^}> "' ${} "
<jD91mZM2> > '' ''\'''${} ''
<{^_^}> "'${} "
<infinisil> Yup :)
<infinisil> (You could cheat without using ''\ via interpolation though)
<infinisil> > '' ${"'"}''${} ''
<{^_^}> "'${} "
<jD91mZM2> Hehe
<infinisil> Have fun with implementing the escaping properly :)
<jD91mZM2> :P
<jD91mZM2> I hate the special escape
<jD91mZM2> just why
<sphalerite> pro tip: use guix instead
<jD91mZM2> inb4 you get bannd
<jD91mZM2> s/bannd/banned
* sphalerite wants hnix to evolve into something that lets you write packages in Haskell
<__monty__> sphalerite: You can write them in dhall for now ; )
<sphalerite> true!
<Drakonis> there's dhall to nix wow
<jD91mZM2> > '' ''\''' ''
<{^_^}> error: syntax error, unexpected $end, expecting IND_STR or DOLLAR_CURLY or IND_STRING_CLOSE, at (string):170:1
<jD91mZM2> infinisil: How do you make three single quotes?
<infinisil> > '' ''' ''
<{^_^}> "'' "
<jD91mZM2> That's two
<infinisil> > '' '''' ''
<{^_^}> "''' "
<infinisil> > '' '''" "''' ''
<{^_^}> "''\" \"'' "
<jD91mZM2> I feel like saying it doesn't make sense, but...
<jD91mZM2> I think I got everything but the special escape now
<infinisil> Nice
<jD91mZM2> Emphasis on "I think"
<jD91mZM2> :^)
<infinisil> :)
<jD91mZM2> > test = 1
<{^_^}> test defined
<jD91mZM2> > '' ''\$${test} ''
<{^_^}> cannot coerce an integer to a string, at (string):169:1
<jD91mZM2> > '' $${test} ''
<{^_^}> "$${test} "
<jD91mZM2> > '' ''$${test} ''
<{^_^}> cannot coerce an integer to a string, at (string):169:1
<jD91mZM2> > '' $''${test} ''
<{^_^}> "$${test} "
<jD91mZM2> So basically, two $s in a row = no interpolation. Any kind of escaping what so ever makes it yes interpolation
drakonis_ has joined #nixos-chat
Drakonis has quit [Ping timeout: 256 seconds]
<infinisil> > 1 + 1
<{^_^}> 2
<jD91mZM2> Woah, really?
<jD91mZM2> I thought it was 3
<infinisil> Somebody messed it up!
<infinisil> > hello
<{^_^}> infinite recursion encountered, at (string):145:10
<sphalerite> > pkgs
<{^_^}> { AAAAAASomeThingsFailToEvaluate = <CODE>; AMB-plugins = <CODE>; AgdaSheaves = <CODE>; AgdaStdlib = <CODE>; CoinMP = <CODE>; DisnixWebService = <CODE>; EBTKS = <CODE>; EmptyEpsilon = <CODE>; Fabric = ...
<infinisil> > :v hello
<{^_^}> hello = hello is not defined
<sphalerite> > writeScriptBin
<{^_^}> <LAMBDA>
<infinisil> Hmm..
<infinisil> > :v _show
<{^_^}> _show = x: if lib.isDerivation x then "<derivation ${x.drvPath}>" else x
<infinisil> > :v pkgs
<{^_^}> pkgs = import <nixpkgs> { config.allowUnfree = true; }
SirMadam has joined #nixos-chat
jD91mZM2 has quit [Quit: WeeChat 2.0]
SirMadam has quit [Quit: Page closed]
pie_ has joined #nixos-chat
drakonis_ has quit [Remote host closed the connection]
Lisanna has quit [Quit: Lisanna]
Ericson2314 has quit [Ping timeout: 256 seconds]
tertle||eltret has joined #nixos-chat
__monty__ has quit [Quit: leaving]
<srk> iirc someone was working on declarative DNS, can't remember who
<srk> generate zones from simple yaml, looks like a good fit :D