From e1e056e82e12fcf434fc4955bd247ba84cd5ec82 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Tue, 16 Sep 2025 16:42:39 +0200 Subject: [PATCH] dependencies: ensure __depPackages.foo.* options are set only once --- modules/dependencies.nix | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/dependencies.nix b/modules/dependencies.nix index 32302a55..e5de3ddf 100644 --- a/modules/dependencies.nix +++ b/modules/dependencies.nix @@ -28,7 +28,15 @@ let }; }; - attrPathType = with types; coercedTo str lib.toList (listOf str); + # Motivation: + # If one were to define `__depPackages.foo.default = "gzip";` in two places (by accident), + # the module system would merge the two definitions as `["gzip" "gzip"]`. + # + # Solution: + # -> Make attrPathType unique so the option can only be set once. + attrPathType = + with types; + unique { message = "attrPathType must be unique"; } (coercedTo str lib.toList (listOf str)); literalExpressionType = lib.types.mkOptionType { name = "literal-expression";