!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1519 Members
Nix programming language268 Servers

Load older messages


SenderMessageTime
3 Aug 2024
@emilazy:matrix.orgemily just putting this here to scare you ''''\'''${a}'' 17:18:06
@glepage:matrix.orgGaétan Lepage

Thanks... I'm not super sure to make it work in my case though

    substituteInPlace src/python/CMakeLists.txt \
      --replace-fail "find_package(pybind11 ${PYBIND11_VER} QUIET)" "find_package(pybind11 QUIET)"
17:18:10
@emilazy:matrix.orgemily pybind11 ''${PYBIND11_VER} 17:18:20
@glepage:matrix.orgGaétan Lepage which is already in a postPatch = '' 17:18:28
@emilazy:matrix.orgemilywelcome to the worst string syntax in the universe!17:18:30
@emilazy:matrix.orgemily oh, but also your "" will cause problems 17:18:43
@emilazy:matrix.orgemily because bash will also try to expand it 17:18:47
@emilazy:matrix.orgemily so you need 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' 17:18:53
@glepage:matrix.orgGaétan Lepage ERROR: pattern find_package\(pybind11\ \ QUIET\) doesn't match anything 17:18:59
@emilazy:matrix.orgemily
In reply to @emilazy:matrix.org
because bash will also try to expand it
because ^
17:19:09
@glepage:matrix.orgGaétan LepageOk, so going with a proper patch file might be the best option here then17:19:32
@emilazy:matrix.orgemily I mean, you can just do --replace-fail 'find_package(pybind11 ''${PYBIND11_VER} QUIET)' 'find_package(pybind11 QUIET)' 17:19:50
@emilazy:matrix.orgemilythat's not so bad17:19:54
@glepage:matrix.orgGaétan Lepage
In reply to @emilazy:matrix.org
that's not so bad
It worked thanks !
17:26:02
@mattsturg:matrix.orgMatt 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
@emilazy:matrix.orgemily oh, you think that's the worst part? try ''\'. or $${. 18:29:02
@emilazy:matrix.orgemily
In reply to @emilazy:matrix.org
just putting this here to scare you ''''\'''${a}''
hence ^ :)
18:29:28
@gunboat_diplomat:matrix.org@gunboat_diplomat:matrix.org left the room.18:36:29
@requiem33:matrix.orgrequiem33 joined the room.18:40:26
@qyriad:katesiria.orgQyriad 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
@mattsturg:matrix.orgMatt 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
@mattsturg:matrix.orgMatt 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
@mjolnir:nixos.orgNixOS Moderation Bot banned @fjeauntyd:matrix.org@fjeauntyd:matrix.org (racism).10:26:05
@thomasjm:matrix.org@thomasjm:matrix.org left the room.12:10:17
@tacticaltaco:matrix.orgtacticaltaco joined the room.22:05:48
5 Aug 2024
@whopteron:matrix.orgwhopteron joined the room.12:24:52
@cochino:matrix.orgcochino joined the room.15:16:08
6 Aug 2024
@likivik:kde.orglikivik joined the room.00:00:08
@berserk.dev:matrix.orgberserk.dev joined the room.21:07:08
@z4ckk:matrix.orgz4ck joined the room.22:35:23

Show newer messages


Back to Room ListRoom Version: 6