!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1518 Members
Nix programming language267 Servers

Load older messages


SenderMessageTime
3 Aug 2024
@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
@philiptaron:matrix.orgPhilip 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
@mattsturg:matrix.orgMatt 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
@mattsturg:matrix.orgMatt Sturgeon I'm surprised elemAt is aborting rather than throwing though 🤔 01:18:28
@daniel573:matrix.orgDaniel Kahlenberg

I have

lib.attrsets.genAttrs [ "nix-inspect" "nixvim-config" "bundix" "feedback" "talon" "rime" "nix-ld-rs" "devenv" ] (name: "input
s.${name}.packages.x86_64.default")
{
  bundix = "inputs.bundix.packages.x86_64.default";
  devenv = "inputs.devenv.packages.x86_64.default";
  feedback = "inputs.feedback.packages.x86_64.default";
  nix-inspect = "inputs.nix-inspect.packages.x86_64.default";
  nix-ld-rs = "inputs.nix-ld-rs.packages.x86_64.default";
  nixvim-config = "inputs.nixvim-config.packages.x86_64.default";
  rime = "inputs.rime.packages.x86_64.default";
  talon = "inputs.talon.packages.x86_64.default";
}

but I want the attrs on the rhs to be attributes not just strings.

How would I achieve that ?

09:56:20
@emilazy:matrix.orgemilyjust drop the quotes09:59:44
@daniel573:matrix.orgDaniel Kahlenberg
In reply to @emilazy:matrix.org
just drop the quotes
Thank you, such a fast solution !
10:01:14
@taffisher:matrix.org@taffisher:matrix.org left the room.19:12:55
@hyperflarex:matrix.orghyperflare left the room.19:16:24
@hyperflarex:matrix.orghyperflare joined the room.19:44:23
@dazai:matrix.orgdazaii'm trying to use colmena with flake-utils so that way I can deploy from my aarch64-linux runner as well as my x86_64-linux runner, but I get meta.nixpkgs must be evaluated in hermetic mode. Anyone run into this? works fine without flake-utils and specifying system = "aarch64-linux" directly https://gist.github.com/abueide/5c8c0fd7bb5c1f70c4ff468748c0375120:17:22
@dazai:matrix.orgdazai left the room.20:47:32

Show newer messages


Back to Room ListRoom Version: 6