feat(users/Profpatsch/netstring): add nix toNetstring* functions
We can easily construct netstrings from nix strings, which is super helpful to inject proper structured data into execline scripts. Change-Id: Ie8bffed285896223db83652eaea868ece43592b9 Reviewed-on: https://cl.tvl.fyi/c/depot/+/3265 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
28bed07694
commit
d41caf2dd6
1 changed files with 12 additions and 0 deletions
|
@ -1,5 +1,17 @@
|
|||
{ lib, pkgs, depot, ... }:
|
||||
let
|
||||
toNetstring = s:
|
||||
"${toString (builtins.stringLength s)}:${s},";
|
||||
|
||||
toNetstringList = xs:
|
||||
lib.concatStrings (map toNetstring xs);
|
||||
|
||||
toNetstringKeyVal = attrs:
|
||||
lib.concatStrings
|
||||
(lib.mapAttrsToList
|
||||
(k: v: toNetstring (toNetstring k + toNetstring v))
|
||||
attrs);
|
||||
|
||||
python-netstring = depot.users.Profpatsch.writers.python3Lib {
|
||||
name = "netstring";
|
||||
} ''
|
||||
|
|
Loading…
Reference in a new issue