|
16 | 16 |
|
17 | 17 | isLinkable = wlib.types.linkable.check; |
18 | 18 | makeForce = lib.mkOverride 0; |
| 19 | + |
| 20 | + componentModule = { |
| 21 | + options = { |
| 22 | + data = mkOption { |
| 23 | + type = types.either wlib.types.linkable types.lines; |
| 24 | + description = "The component's inlined text or path"; |
| 25 | + }; |
| 26 | + module = mkOption { |
| 27 | + type = types.nullOr types.str; |
| 28 | + default = null; |
| 29 | + description = "The component's module, to be imported by `import qs.<module>`"; |
| 30 | + }; |
| 31 | + }; |
| 32 | + }; |
19 | 33 | in |
20 | 34 | { |
21 | 35 | imports = [ wlib.modules.default ]; |
|
31 | 45 | ''; |
32 | 46 | }; |
33 | 47 | components = mkOption { |
34 | | - type = types.attrsOf (types.either wlib.types.linkable types.lines); |
| 48 | + type = types.attrsOf (wlib.types.spec componentModule); |
35 | 49 | default = { }; |
36 | 50 | description = "Quickshell components to include in the configuration"; |
37 | 51 | }; |
|
62 | 76 | firstChar = builtins.substring 0 1 name; |
63 | 77 | rest = builtins.substring 1 (-1) name; |
64 | 78 | capitalizedName = (lib.toUpper firstChar) + rest; |
65 | | - linkable = isLinkable val; |
| 79 | + linkable = isLinkable val.data; |
66 | 80 | in |
67 | 81 | { |
68 | 82 | name = "${name}Component"; |
69 | 83 | value = { |
70 | | - content = mkIf (!linkable) val; |
71 | | - builder = mkIf linkable ''ln -s ${val} "$2"''; |
| 84 | + content = mkIf (!linkable) val.data; |
| 85 | + builder = mkIf linkable ''ln -s ${val.data} "$2"''; |
72 | 86 | output = makeForce config.generated.output; |
73 | | - relPath = makeForce "${config.binName}-config/${capitalizedName}.qml"; |
| 87 | + relPath = makeForce "${config.binName}-config/${ |
| 88 | + if val.module != null then "${lib.replaceString "." "/" val.module}/" else "" |
| 89 | + }${capitalizedName}.qml"; |
74 | 90 | }; |
75 | 91 | } |
76 | 92 | ) config.components |
|
0 commit comments