about summary refs log blame commit diff
path: root/nix/netstring/fromString.nix
blob: dcd688a8b0b3914c5f8cf668a773e98a0c18976a (plain) (tree)
1
2
3
4
5
6
7
8
9
10








                                                                               
{ ... }:
# convert any nix string into a netstring
# (prefixed by its length) according to https://en.wikipedia.org/wiki/Netstring
#
# Examples:
#   netstring.fromString "foo"
#   => "3:foo,"
#   netstring.fromString ""
#   => "0:,"
s: "${toString (builtins.stringLength s)}:${s},"