diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-29 13:45:30 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2013-10-29 13:45:30 +0100 |
commit | 0afdb1e933b2089e7cf00df4ef1646d639f70d81 (patch) | |
tree | 8fb947dcc0868f873e45f9c0581db169e540e572 /lib | |
parent | 57e9fd8bcf486a6abf4a84f62a5350eb94d6fd0d (diff) | |
download | nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar.gz nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar.bz2 nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar.lz nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar.xz nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.tar.zst nixlib-0afdb1e933b2089e7cf00df4ef1646d639f70d81.zip |
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".
Diffstat (limited to 'lib')
-rw-r--r-- | lib/types.nix | 8 |
1 files changed, 8 insertions, 0 deletions
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; |