modules/dependencies: coerce __depPackages attr-paths to list

This commit is contained in:
Matt Sturgeon 2025-04-21 08:47:28 +01:00
parent 1164b39963
commit fb80e0d0b5
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299

View file

@ -21,13 +21,15 @@ let
if properties.example._type or null == "literalExpression" then if properties.example._type or null == "literalExpression" then
properties.example properties.example
else else
rec { {
_type = "literalExpression"; _type = "literalExpression";
text = "pkgs.${lib.showAttrPath path}"; text = "pkgs.${lib.showAttrPath properties.example}";
path = lib.toList properties.example; path = properties.example;
}; };
}; };
}; };
attrPathType = with types; coercedTo str lib.toList (listOf str);
in in
{ {
options = { options = {
@ -36,17 +38,17 @@ in
types.submodule { types.submodule {
options = { options = {
default = lib.mkOption { default = lib.mkOption {
type = with types; either str (listOf str); type = attrPathType;
description = '' description = ''
Default name (or path) for this package. Attribute path for this dependency's default package, relative to `pkgs`.
''; '';
example = "git"; example = "git";
}; };
example = lib.mkOption { example = lib.mkOption {
type = with types; nullOr str; type = types.nullOr attrPathType;
description = '' description = ''
Example of another package to use instead of the default. Attribute path for an alternative package that provides dependency, relative to `pkgs`.
''; '';
example = "gitMinimal"; example = "gitMinimal";
default = null; default = null;