Add option type "str" for unique strings

An annoying and dangerous property of "types.string" is that it merges
multiple definitions by concatenating them, which almost never
produces a sensible result.  (Those options for which it does make
sense typically should use "types.lines" instead, and things only work
because the option definitions already end in a newline.)  Of course,
you can use "types.uniq types.string", but that's rather verbose, and
inconsistent with other basic types like "types.int".

Changing the behaviour of "types.string" to be unique by default is
not an option, given the large number of options that use it.  So
instead, we now have "types.str", which is equivalent to "types.uniq
types.string".
This commit is contained in:
Eelco Dolstra 2013-10-29 13:45:30 +01:00
parent 57e9fd8bcf
commit 0afdb1e933

View file

@ -54,6 +54,14 @@ rec {
check = builtins.isInt;
};
str = mkOptionType {
name = "string";
check = builtins.isString;
merge = mergeOneOption;
};
# Deprecated; should not be used because it quietly concatenates
# strings, which is usually not what you want.
string = mkOptionType {
name = "string";
check = builtins.isString;