From 6012c399c1408c56a2b68ff48f401a7daceccf59 Mon Sep 17 00:00:00 2001 From: Valentin Gagarin Date: Tue, 15 Oct 2024 23:58:06 +0200 Subject: [PATCH] smarter indent this allows writing the beginning of the indented string at the desired indentation --- lib.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib.nix b/lib.nix index 87a66df..7e81147 100644 --- a/lib.nix +++ b/lib.nix @@ -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: