Nix Language | 1922 Members | |
| Nix programming language | 357 Servers |
| Sender | Message | Time |
|---|---|---|
| 17 May 2026 | ||
Yes, but the two quotes ('') of the escape sequence merge with the single quote ' from before the escape sequence, which then results in a different string. That is the root cause of my question. :D | 13:58:09 | |
| oh, I did not see the original question before the example, my bad. | 13:58:38 | |
I don't think so. That would be \${foo}. $$ still evaluates to two dollar signs, even in "normal" strings. | 14:01:01 | |
| I misunderstood what you wanted, sorry | 14:04:34 | |
| So basically with naive escaping applied:
And my question is basically if there is a more idiomatic why than the following:
I stripped the opening and closing quotes of the indented string for better readability. | 14:07:09 | |
| * So basically with naive escaping applied:
And my question is basically if there is a more idiomatic why than the following:
I skipped the opening and closing quotes of the indented string (in the middle) for better readability. | 14:08:10 | |
| No, I don't think so | 14:34:18 | |
| I remember running across this during the deprecations | 14:34:28 | |
This is the reason why ''\{ could not be deprecated | 14:34:54 | |
| Another question I was also stumbling into while working on this topic. Is there an idiomatic why to keep some trailing whitespace in indented strings? Let's consider the following code:
If I remove the first line of the markdown snipped (i.e. the "headline"), the additional indent of the code snippet gets trimmed. So instead of
the resulting string value would be:
Is there some why to represent indented code block inside an indented string? | 18:19:42 | |
| I guess I could do the following:
This would basically use the | 18:25:28 | |
| 22:24:07 | ||
| 23:19:37 | ||
| 23:41:13 | ||
| 18 May 2026 | ||
In reply to @trudwin:matrix.orgNo, this is indeed the best currently available workaround | 07:30:41 | |
| 10:03:14 | ||
| 14:16:59 | ||
| I find myself doing `// optionalAttrs (attrs ? a) { inherit (attrs) a; }` a lot. Is there a nice way to shorten that? I naively tried `attrs: attrname: optionalAttrs (attrs ? "${attrname}") { inherit (attrs) "${attrname}"; }` but dynamic attributes aren't allowed in inherit, I assume `{ ${attrname} = attrs.${attrname}; }` would work but "nice" was left behind somewhere along the road... | 15:47:25 | |
Uh, is this not just a fancy filterAttrs? | 15:48:52 | |
// filterAttrs (n: _: n == "attrname") attrs | 15:49:30 | |
| filterAttrs is heavier, requiring a whole removeAttrs | 15:53:23 | |
| I personally choose not to use optionalAttrs in that way, instead choosing
xovidium has said that empty merges are free on new nix versions though | 15:54:44 | |
| (I've been working close to the metal on mkDerivation, which makes me performance minded) | 15:55:17 | |
| * | 15:57:12 | |
| I have the same reservation about filterAttrs. The lambda also kinda obscures what's going on, it's too powerful in a way. | 17:03:03 | |
| Hadn't considered a dynamic attribute with if-then-else. Useful for multiple attributes at a time but I do feel like it's more obscure. | 17:05:00 | |
| 17:09:05 | ||
| 19 May 2026 | ||
| 14:56:39 | ||
| 15:41:02 | ||
| Redacted or Malformed Event | 20:24:00 | |