smarter indent

this allows writing the beginning of the indented string at the desired
indentation
This commit is contained in:
Valentin Gagarin 2024-11-13 15:24:41 +01:00 committed by Valentin Gagarin
parent e38960661c
commit 29839f82d7

View file

@ -36,7 +36,15 @@ rec {
splitLines = s: with builtins; filter (x: !isList x) (split "\n" s); splitLines = s: with builtins; filter (x: !isList x) (split "\n" s);
indent = prefix: 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 { types = rec {
collection = elemType: collection = elemType: