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.
This commit is contained in:
Eelco Dolstra 2013-02-11 15:28:41 +01:00
parent 26dd2dc425
commit e4ce304333

View file

@ -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;