about summary refs log tree commit diff
path: root/lib/tests/modules
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2024-02-10 02:52:45 +0100
committerGitHub <noreply@github.com>2024-02-10 02:52:45 +0100
commitf37ba1976518f61217dcee655412288b09441cde (patch)
tree06392f647e18d6b283f46e49bf66abb9d1b71910 /lib/tests/modules
parentddc9133e53aa4a48135a6e9e50277c327ac73b72 (diff)
parent542f5d4f4d80a35d8f03aa5cf2a2a0b1a0345c41 (diff)
downloadnixlib-f37ba1976518f61217dcee655412288b09441cde.tar
nixlib-f37ba1976518f61217dcee655412288b09441cde.tar.gz
nixlib-f37ba1976518f61217dcee655412288b09441cde.tar.bz2
nixlib-f37ba1976518f61217dcee655412288b09441cde.tar.lz
nixlib-f37ba1976518f61217dcee655412288b09441cde.tar.xz
nixlib-f37ba1976518f61217dcee655412288b09441cde.tar.zst
nixlib-f37ba1976518f61217dcee655412288b09441cde.zip
Merge pull request #284512 from hercules-ci/lib-types-unique-merge
lib.types.unique: Check inner type deeply
Diffstat (limited to 'lib/tests/modules')
-rw-r--r--lib/tests/modules/types-unique.nix27
1 files changed, 27 insertions, 0 deletions
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;
+    };
+  };
+}