!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1948 Members
Nix programming language361 Servers

Load older messages


SenderMessageTime
8 Sep 2021
@figsoda:matrix.orgfigsodaguess so12:05:24
@cdepillabout:matrix.orgcdepillabout
In reply to @cdepillabout:matrix.org

How can I use a quoted let binding?

For instance, how would I use assert after the in:

let "assert" = 3; in ...
I posted this question on Discourse in case anyone is interested in following along: https://discourse.nixos.org/t/how-to-use-quoted-let-bindings/14925
12:47:07
@polykernel:kde.orgpolykernelI may be wrong but I don't think there is any way to override top-level keywords unless you use scopedImport.14:06:58
@polykernel:kde.orgpolykernel * I may be wrong but I don't think there is any way to override top-level keywords.14:07:25
@ilkecan:matrix.orgilkecan Are builtins such as throw s, trace e1 e2 etc. considered an expression in Nix? 15:11:38
@sternenseemann:systemli.orgsterniyes you can shadow them even15:14:03
@sternenseemann:systemli.orgsternibut assert has special syntax, so it is handled specially15:14:16
@ilkecan:matrix.orgilkecanI see, thank you.15:31:18
9 Sep 2021
@cdepillabout:matrix.orgcdepillabout
In reply to @polykernel:kde.org
I may be wrong but I don't think there is any way to override top-level keywords.

Just for clarification, I'm not trying to override assert in my example, I'm just trying to use a binding that happens to be called assert.

I'd be happy for an example of how to use any sort of quoted binding. For instance:

let "this is an identifier with spaces" = 3; in ...
02:38:57
@cdepillabout:matrix.orgcdepillabout
In reply to @polykernel:kde.org
I may be wrong but I don't think there is any way to override top-level keywords.
*

Just for clarification, I'm not trying to override the assert keyword in my example, I'm just trying to use a binding that happens to be called assert.

I'd be happy for an example of how to use any sort of quoted binding. For instance:

let "this is an identifier with spaces" = 3; in ...
11:11:03
@sternenseemann:systemli.orgsterni

Behold variable function parameter count trick in nix:

> concatMany = s: { inherit s; __toString = self: self.s; __functor = self: s': self // { s = self.s + s'; }; }
> "${concatMany "foo" " " "bar"}"
"foo bar"
> "${concatMany "yes" ", " "you " "saw" " it" "!"}"
"yes, you saw it!"
21:05:13
@sternenseemann:systemli.orgsterni A printf type function is also possible, but boring in comparison because the format string mandates the number of arguments so you don't need to need the dance of return val which can be called and is a string 21:06:17
@sternenseemann:systemli.orgsterni * A printf type function is also possible, but boring in comparison because the format string mandates the number of arguments so you don't need to need the dance of return val which can be called and is a "string" 21:06:22
@infinisil:matrix.orginfinisil sterni: Niiiice 21:35:41
@infinisil:matrix.orginfinisilNever saw __toString and __functor be combined in this way21:36:13
@sternenseemann:systemli.orgsterni

Simple printf implementation with only %s and %%:

{ lib, ... }:

formatString:

let
  tokenWithArg = token: builtins.elem token [
    "%s"
  ];

  tokens = lib.flatten (builtins.split "(%.)" formatString);
  argsNeeded = builtins.length (builtins.filter tokenWithArg tokens);

  format = args: (builtins.foldl' ({ out ? "", argIndex ? 0 }: token: {
    argIndex = argIndex + (if tokenWithArg token then 1 else 0);
    out =
      /**/ if token == "%s" then out + builtins.elemAt args argIndex
      else if token == "%%" then out + "%"
      else out + token;
  }) {} tokens).out;

  accumulateArgs = argCount: args:
    if argCount > 0
    then arg: accumulateArgs (argCount - 1) (args ++ [ arg ])
    else format args;
in

accumulateArgs argsNeeded []
21:37:13
10 Sep 2021
@she:khinah.xyzshekhinah left the room.05:12:13
11 Sep 2021
@marillindie:matrix.orgMarillindiƫ joined the room.05:26:50
@mnikkel:matrix.orgMarkN joined the room.14:48:17
@yusdacra:nixos.devyusdacra changed their profile picture.16:32:11
13 Sep 2021
@jb:vk3.wtfjbedo joined the room.03:41:22
@vk3wtf:matrix.orgjbedo left the room.03:41:24
@jb:vk3.wtfjbedo changed their display name from vk3wtf to jbedo.03:41:29
@jb:vk3.wtfjbedo changed their display name from jbedo to vk3wtf.05:57:10
@jb:vk3.wtfjbedo changed their display name from vk3wtf to jbedo.05:57:56
@amemulo:matrix.orgefim

Can anyone help me
I'm on nix-os trying debug & create sample configuration similar to this one
https://github.com/efim/nix-searx-container-example/blob/master/non-flake-config.nix

but for "searxng", so that searx plugins would be installed just as easily

on previous week this builting.fetchGit worked and worked great
(lib.fetchFromGitHub - infinitely recursed, it seems because i've been importing overlays to pkgs from flakes, and to get flakes final lib has to be built, etc)

but today then I try to do
sudo nixos-container update bar --config-file non-flake-config.nix
I get prompted for "email+password" authentication on github
And even if I provide correct auth - I get error
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Over weekend I've been refactoring NixOS config, but have no idea what could have caused it

When I try to evaluate statement with lib.fetchGit in nix-repl it works well!
and git fetch --all asks for my ssh key, not email =C
( maybe @gytis would know?)

12:24:44
@amemulo:matrix.orgefim *

Can anyone help me
I'm on nix-os trying debug & create sample configuration similar to this one
https://github.com/efim/nix-searx-container-example/blob/master/non-flake-config.nix

but for "searxng", so that searx plugins would be installed just as easily

on previous week this builting.fetchGit worked and worked great
(lib.fetchFromGitHub - infinitely recursed, it seems because i've been importing overlays to pkgs from flakes, and to get flakes final lib has to be built, etc)

but today then I try to do
sudo nixos-container update bar --config-file non-flake-config.nix
I get prompted for "email+password" authentication on github
And even if I provide correct auth - I get error
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Over weekend I've been refactoring NixOS config, but have no idea what could have caused it

When I try to evaluate statement with lib.fetchGit in nix-repl it works well!
and git fetch --all asks for my ssh key, not email =C
( maybe @gytis would know?)

12:25:08
@amemulo:matrix.orgefim *

Can anyone help me
I'm on nix-os trying debug & create sample configuration similar to this one
https://github.com/efim/nix-searx-container-example/blob/master/non-flake-config.nix

but for "searxng", so that searx plugins would be installed just as easily

on previous week this builting.fetchGit worked and worked great
(lib.fetchFromGitHub - infinitely recursed, it seems because i've been importing overlays to pkgs from flakes, and to get flakes final lib has to be built, etc)

but today then I try to do
sudo nixos-container update bar --config-file non-flake-config.nix
I get prompted for "email+password" authentication on github
And even if I provide correct auth - I get error
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Over weekend I've been refactoring NixOS config, but have no idea what could have caused it

When I try to evaluate statement with lib.fetchGit in nix-repl it works well!
and git fetch --all asks for my ssh key, not email =C

12:25:43
@amemulo:matrix.orgefimI guess this is solved: I think the repo is public, but there's a mistake in the link so fetcher tries to check whether there's some private repo with that name12:33:54
@legendofmiracles:matrix.orglegendofmiracles changed their profile picture.23:49:09

Show newer messages


Back to Room ListRoom Version: 6