From 0afdb1e933b2089e7cf00df4ef1646d639f70d81 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 29 Oct 2013 13:45:30 +0100 Subject: [PATCH] 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". --- lib/types.nix | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/types.nix b/lib/types.nix index 34d06a9144fe..8deb379c25a9 100644 --- a/lib/types.nix +++ b/lib/types.nix @@ -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;