smarter indent

this allows writing the beginning of the indented string at the desired
indentation
This commit is contained in:
Valentin Gagarin 2024-10-15 23:58:06 +02:00
parent c1dd3bdfab
commit 6012c399c1

10
lib.nix
View file

@ -36,7 +36,15 @@ rec {
splitLines = s: with builtins; filter (x: !isList x) (split "\n" s);
indent = prefix: s:
join "\n" (map (x: if x == "" then x else "${prefix}${x}") (splitLines s));
with lib.lists;
let
lines = splitLines s;
in
join "\n" (
[ (head lines) ]
++
(map (x: if x == "" then x else "${prefix}${x}") (tail lines))
);
types = rec {
collection = elemType: