Sender | Message | Time |
---|---|---|
23 Apr 2024 | ||
Qyriad | // isn't something like @ or ... which changes the semantics of something. // is just flat out an operator, like addition and subtraction. but rather than operating on integers (like + and - ), // operates on attribute sets. both side ("operands") must be attribute sets. the result of leftHandSide // rightHandSide is another attribute set, which has all the attributes in leftHandSide and all the attributes in rightHandSide , where overlapping values take precedence from rightHandSide It's a dictionary merge, basically | 20:41:55 |
Qyriad | .override is a different story 😅 | 20:42:10 |
Grimmauld | In reply to @qyriad:katesiria.orgah so its mkMerge that doesn't complain if stuff overlaps? Interesting | 20:42:50 |
Grimmauld | i will use it then | 20:42:56 |
Qyriad | gonna have to lookup mkMerge one sec… | 20:43:20 |
Qyriad | oh dear okay, so. mkMerge is conceptually similar, but operates at a different level. mkMerge merges NixOS modules. // merges any arbitrary attrsets | 20:44:09 |
Qyriad | It's like the difference between lib.mkIf and lib.optionalAttrs , if you're familiar with those two | 20:44:27 |
Grimmauld | In reply to @qyriad:katesiria.orgwait what, whats the actual diff? | 20:45:39 |
Grimmauld | i know both but how are they different? | 20:45:54 |
Grimmauld | Download image.png | 20:47:18 |
Grimmauld | and this is a valid replacement, so i don't quite follow how mkMerge and // is differnt if mkMerge didn'texplode before | 20:47:41 |
Grimmauld | it does the same thing, i checked | 20:47:48 |
Grimmauld | (gotta say i should have learnt // earlier) | 20:48:14 |
Grimmauld | there is some places where i use mkMerge in conjunction with mapAttrsToList, // obviously wouldn't work for that assuming no fold magic. // is a binary operator, but to me it really looks like mkMerge just is the full accumulator function to the operator // like sum is the accumulator to the operator + | 20:50:12 |
Qyriad | In reply to@grimmauld:grimmauld.de mkIf is probably easiet to demonstrate like this: Compare optionalAttrs : | 20:54:24 |
Grimmauld | aaahhh interesting! That makes sense, ty! | 20:55:00 |
Qyriad | I actually haven't used mkMerge myself so I'm not actually sure what cases its used in, but I did just look at the implementation, which is this: which is definitely not the same as // . to figure out exactly what mkMerge does (since it doesn't seem to be documented…) I'd have to see what NixOS' module system does when it sees a module of _type = "merge"; | 20:56:30 |
Qyriad | but in general, it's the NixOS module system that does anything with mkMerge at all. it only makes sense on NixOS module attrsets | 20:57:27 |
Grimmauld | it does work for all attrsets though, at least from my testing XD | 20:58:02 |
Grimmauld | but yeah that makes sense, guess i'll have to go through my stuff and decide whether or not it makes sense then | 20:58:29 |
Qyriad | In reply to@grimmauld:grimmauld.deI mean definitely works in the sense that it does something, for attrsets, but try it on a derivation and you might run into some trouble =P | 20:59:42 |
Grimmauld | Fair fair XD | 21:01:03 |
Grimmauld | Thank you for the explanations, really helped | 21:04:32 |
Qyriad | no problem! glad to help! | 21:05:02 |
24 Apr 2024 | ||
Daniel Tomov joined the room. | 06:40:22 | |
stablejoy changed their profile picture. | 08:59:09 | |
infinisil | Qyriad Grimmauld Btw there's a newish room specifically for the module system: https://matrix.to/#/%23modules:nixos.org | 14:38:01 |
Yuri joined the room. | 18:47:47 | |
@zirpu:matrix.org left the room. | 23:50:09 | |
25 Apr 2024 | ||
dpjyoo joined the room. | 17:17:34 |