3 Aug 2024 |
emily | pybind11 ''${PYBIND11_VER} | 17:18:20 |
Gaétan Lepage | which is already in a postPatch = '' | 17:18:28 |
emily | welcome to the worst string syntax in the universe! | 17:18:30 |
emily | oh, but also your "" will cause problems | 17:18:43 |
emily | because bash will also try to expand it | 17:18:47 |
emily | so you need 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' | 17:18:53 |
Gaétan Lepage | ERROR: pattern find_package\(pybind11\ \ QUIET\) doesn't match anything | 17:18:59 |
emily | In reply to @emilazy:matrix.org because bash will also try to expand it because ^ | 17:19:09 |
Gaétan Lepage | Ok, so going with a proper patch file might be the best option here then | 17:19:32 |
emily | I mean, you can just do --replace-fail 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' 'find_package(pybind11 QUIET)' | 17:19:50 |
emily | that's not so bad | 17:19:54 |
Gaétan Lepage | In reply to @emilazy:matrix.org that's not so bad It worked thanks ! | 17:26:02 |
Matt Sturgeon | In reply to @emilazy:matrix.org welcome to the worst string syntax in the universe! Nix's indented string syntax is always fun!
'' to start/end
''' renders literally as ''
''$ renders literally as $ And leading newlines before the first non-blank line are striped (though not trailing lines) | 18:27:32 |
emily | oh, you think that's the worst part? try ''\' . or $${ . | 18:29:02 |
emily | In reply to @emilazy:matrix.org just putting this here to scare you ''''\'''${a}'' hence ^ :) | 18:29:28 |
| @gunboat_diplomat:matrix.org left the room. | 18:36:29 |
| requiem33 joined the room. | 18:40:26 |
Qyriad | Sometimes it can just be clearer to just do something like
let bashFoo = "\${foo}"; in ''
echo "${bashFoo}"
'';
just to avoid this madness | 22:06:42 |
4 Aug 2024 |
Matt Sturgeon | If it's a large enough block of text to justify it, you can always put it in a separate file and readFile it. If you also need to include a handful of nix vars/expressions in the string, you could map them to bash vars using lib.toShellVars :
{
env = {
foo = "bar";
sum = 1 + 2;
hello = lib.getExe pkgs.hello;
PATH = lib.makeBinPath [
pkgs.git
pkgs.cowsay
];
};
text = ''
${lib.toShellVars env}
export PATH
${builtins.readFile ./script.sh}
'';
}
| 00:05:43 |
Matt Sturgeon | * If it's a large enough block of text to justify it, you can always put it in a separate file and readFile it. If you also need to include a handful of nix vars/expressions in the string, you could map them to bash vars using lib.toShellVars :
rec {
env = {
foo = "bar";
sum = 1 + 2;
hello = lib.getExe pkgs.hello;
PATH = lib.makeBinPath [
pkgs.git
pkgs.cowsay
];
};
text = ''
${lib.toShellVars env}
export PATH
${builtins.readFile ./script.sh}
'';
}
| 00:06:03 |
| NixOS Moderation Bot banned @fjeauntyd:matrix.org (racism). | 10:26:05 |
| @thomasjm:matrix.org left the room. | 12:10:17 |
| tacticaltaco joined the room. | 22:05:48 |
5 Aug 2024 |
| whopteron joined the room. | 12:24:52 |
| cochino joined the room. | 15:16:08 |
6 Aug 2024 |
| likivik joined the room. | 00:00:08 |
| berserk.dev joined the room. | 21:07:08 |
| z4ck joined the room. | 22:35:23 |
Philip Taron (UTC-8) | I don't think I really understand tryEval :
$ nix-instantiate --strict --eval --expr 'builtins.tryEval (builtins.elemAt [] 1)'
error:
… while calling the 'tryEval' builtin
at «string»:1:1:
1| builtins.tryEval (builtins.elemAt [] 1)
| ^
… while calling the 'elemAt' builtin
at «string»:1:19:
1| builtins.tryEval (builtins.elemAt [] 1)
| ^
error: list index 1 is out of bounds
What makes some error able to be tryEval 'd away and what makes it not able to be?
| 23:50:37 |
7 Aug 2024 |
Matt Sturgeon | I'd have to refer to documentation to give the exact answer, but it depends on how the error was produced.
For example throw can be "caught" by tryEval , but I believe abort cannot.
I'd expect most errors (e.g. failed assert statements) to be the equivalent of a throw rather than an abort . | 01:16:32 |