From b78ba9bc68b003288d56bab62693ea28e2cdfd76 Mon Sep 17 00:00:00 2001 From: Robert Hensing Date: Sun, 28 Jan 2024 14:09:27 +0100 Subject: lib.types.unique: Check inner type deeply This doesn't change uniq. Why not? - In NixOS it seems that uniq is only used with simple types that are fully checked by t.check. - It exists for much longer and is used more widely. - I believe we should deprecate it, because unique was already better. - unique can be a proving ground. --- lib/tests/modules/types-unique.nix | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lib/tests/modules/types-unique.nix (limited to 'lib/tests/modules') diff --git a/lib/tests/modules/types-unique.nix b/lib/tests/modules/types-unique.nix new file mode 100644 index 000000000000..115be0126975 --- /dev/null +++ b/lib/tests/modules/types-unique.nix @@ -0,0 +1,27 @@ +{ lib, ... }: +let + inherit (lib) mkOption types; +in +{ + options.examples = mkOption { + type = types.lazyAttrsOf + (types.unique + { message = "We require a single definition, because seeing the whole value at once helps us maintain critical invariants of our system."; } + (types.attrsOf types.str)); + }; + imports = [ + { examples.merged = { b = "bee"; }; } + { examples.override = lib.mkForce { b = "bee"; }; } + ]; + config.examples = { + merged = { + a = "aye"; + }; + override = { + a = "aye"; + }; + badLazyType = { + a = true; + }; + }; +} -- cgit 1.4.1