How to write single backslash

If I do nix repl followed by "\\" I get just that, a double backslash. The reason I’m asking is because I want to use Nix to configure my alacritty keybindings and for that I need lots of

        chars = "\\u001b0";
        key = "Key0";
        mods = "Alt";

as mentioned here but the output when using this with builtins.toJSON is


when it needs to be single slashes in alacritty.yml

That actually is a single \, it’s just that JSON needs to escape it with \\ as well

You can verify the actual contents of strings like this using trace

nix-repl> builtins.trace "\\backslashes\\" {}
trace: \backslashes\
{ }

nix-repl> builtins.trace ''\\backslashes\\'' {}
trace: \\backslashes\\
{ }

In any case, the source code seems to indicate that double backslashes are replaced with single backslashes, but it seems like a hack and I’m not sure about whether it’s a good way of doing it.

Thanks the replaceStrings [ "\\\\" ] [ "\\" ] does the trick so that I end up with \u in my config file. Was a bit lazy of me to not check the source, sorry :frowning: