From e4ce304333965231338bdefe0f53409d2055323c Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 11 Feb 2013 15:28:41 +0100 Subject: [PATCH] =?UTF-8?q?types.nix:=20Add=20a=20=E2=80=98lines=E2=80=99?= =?UTF-8?q?=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is like types.string, but values are merged by putting a newline in between them. This is mostly useful for configuration file options, where we don't want values accidentally ending up on the same line. Note that almost all options with string type in NixOS should either be unmergable (i.e. should be marked with ‘types.uniq’) or should actually be of type ‘lines’. So it might make sense to remove the merge function for the ‘string’ type eventually. --- pkgs/lib/types.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkgs/lib/types.nix b/pkgs/lib/types.nix index 1cb1185b8bb..6ddac61d91b 100644 --- a/pkgs/lib/types.nix +++ b/pkgs/lib/types.nix @@ -68,6 +68,14 @@ rec { merge = lib.concatStrings; }; + # Like ‘string’, but add newlines between every value. Useful for + # configuration file contents. + lines = mkOptionType { + name = "string"; + check = lib.traceValIfNot builtins.isString; + merge = lib.concatStringsSep "\n"; + }; + envVar = mkOptionType { name = "environment variable"; inherit (string) check;