summary refs log tree commit diff
path: root/pkgs/lib/types.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-02-11 15:28:41 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-02-11 15:32:24 +0100
commite4ce304333965231338bdefe0f53409d2055323c (patch)
treea350f866652984861c16e6983ca45c56956b1291 /pkgs/lib/types.nix
parent26dd2dc4255030ea0cfc1074b040d1b3712992cd (diff)
downloadnixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar.gz
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar.bz2
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar.lz
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar.xz
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.tar.zst
nixpkgs-e4ce304333965231338bdefe0f53409d2055323c.zip
types.nix: Add a ‘lines’ type
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.
Diffstat (limited to 'pkgs/lib/types.nix')
-rw-r--r--pkgs/lib/types.nix8
1 files changed, 8 insertions, 0 deletions
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;