|
| 1 | +{ config, lib, ... }: |
| 2 | +let |
| 3 | + tomlFmt = config.pkgs.formats.toml { }; |
| 4 | + conf = |
| 5 | + let |
| 6 | + base = tomlFmt.generate "helix-config" config.settings; |
| 7 | + in |
| 8 | + if config.extraSettings != "" then |
| 9 | + config.pkgs.concatText "helix-config" [ |
| 10 | + base |
| 11 | + (config.pkgs.writeText "extraSettings" config.extraSettings) |
| 12 | + ] |
| 13 | + else |
| 14 | + base; |
| 15 | + langs = tomlFmt.generate "helix-languages-config" config.languages; |
| 16 | + ignore = config.pkgs.writeText "helix-ignore" (lib.strings.concatLines config.ignores); |
| 17 | + themes = lib.mapAttrsToList ( |
| 18 | + name: value: |
| 19 | + let |
| 20 | + fname = "helix-theme-${name}"; |
| 21 | + in |
| 22 | + { |
| 23 | + name = "themes/${name}.toml"; |
| 24 | + path = |
| 25 | + if lib.isString value then config.pkgs.writeText fname value else (tomlFmt.generate fname value); |
| 26 | + } |
| 27 | + ) config.themes; |
| 28 | +in |
1 | 29 | { |
2 | | - wlib, |
3 | | - lib, |
4 | | - ... |
5 | | -}: |
6 | | -wlib.wrapModule ( |
7 | | - { config, wlib, ... }: |
8 | | - let |
9 | | - tomlFmt = config.pkgs.formats.toml { }; |
10 | | - conf = |
11 | | - let |
12 | | - base = tomlFmt.generate "helix-config" config.settings; |
13 | | - in |
14 | | - if config.extraSettings != "" then |
15 | | - config.pkgs.concatText "helix-config" [ |
16 | | - base |
17 | | - (config.pkgs.writeText "extraSettings" config.extraSettings) |
18 | | - ] |
19 | | - else |
20 | | - base; |
21 | | - langs = tomlFmt.generate "helix-languages-config" config.languages; |
22 | | - ignore = config.pkgs.writeText "helix-ignore" (lib.strings.concatLines config.ignores); |
23 | | - themes = lib.mapAttrsToList ( |
24 | | - name: value: |
25 | | - let |
26 | | - fname = "helix-theme-${name}"; |
27 | | - in |
28 | | - { |
29 | | - name = "themes/${name}.toml"; |
30 | | - path = |
31 | | - if lib.isString value then config.pkgs.writeText fname value else (tomlFmt.generate fname value); |
32 | | - } |
33 | | - ) config.themes; |
34 | | - in |
35 | | - { |
36 | | - options = { |
37 | | - settings = lib.mkOption { |
38 | | - type = tomlFmt.type; |
39 | | - description = '' |
40 | | - General settings |
41 | | - See <https://docs.helix-editor.com/configuration.html> |
42 | | - ''; |
43 | | - default = { }; |
44 | | - }; |
45 | | - extraSettings = lib.mkOption { |
46 | | - type = lib.types.lines; |
47 | | - default = ""; |
48 | | - description = '' |
49 | | - Extra lines appended to the config file. |
50 | | - This can be used to maintain order for settings. |
51 | | - ''; |
52 | | - }; |
53 | | - languages = lib.mkOption { |
54 | | - type = tomlFmt.type; |
55 | | - description = '' |
56 | | - Language specific settings |
57 | | - See <https://docs.helix-editor.com/languages.html> |
58 | | - ''; |
59 | | - default = { }; |
60 | | - }; |
61 | | - themes = lib.mkOption { |
62 | | - type = lib.types.attrsOf ( |
63 | | - lib.types.oneOf [ |
64 | | - tomlFmt.type |
65 | | - lib.types.lines |
66 | | - ] |
67 | | - ); |
68 | | - description = '' |
69 | | - Themes to add to config. |
70 | | - See <https://docs.helix-editor.com/themes.html> |
71 | | - ''; |
72 | | - default = { }; |
73 | | - }; |
74 | | - ignores = lib.mkOption { |
75 | | - type = lib.types.listOf lib.types.nonEmptyStr; |
76 | | - default = [ ]; |
77 | | - description = '' |
78 | | - List of paths to be ignored by the file-picker. |
79 | | - The format is the same as in .gitignore. |
80 | | - ''; |
81 | | - }; |
| 30 | + _class = "wrapper"; |
| 31 | + options = { |
| 32 | + settings = lib.mkOption { |
| 33 | + type = tomlFmt.type; |
| 34 | + description = '' |
| 35 | + General settings |
| 36 | + See <https://docs.helix-editor.com/configuration.html> |
| 37 | + ''; |
| 38 | + default = { }; |
| 39 | + }; |
| 40 | + extraSettings = lib.mkOption { |
| 41 | + type = lib.types.lines; |
| 42 | + default = ""; |
| 43 | + description = '' |
| 44 | + Extra lines appended to the config file. |
| 45 | + This can be used to maintain order for settings. |
| 46 | + ''; |
| 47 | + }; |
| 48 | + languages = lib.mkOption { |
| 49 | + type = tomlFmt.type; |
| 50 | + description = '' |
| 51 | + Language specific settings |
| 52 | + See <https://docs.helix-editor.com/languages.html> |
| 53 | + ''; |
| 54 | + default = { }; |
82 | 55 | }; |
83 | | - config.package = lib.mkDefault config.pkgs.helix; |
84 | | - config.env = { |
85 | | - XDG_CONFIG_HOME = builtins.toString ( |
86 | | - config.pkgs.linkFarm "helix-merged-config" ( |
87 | | - map |
88 | | - (a: { |
89 | | - inherit (a) path; |
90 | | - name = "helix/" + a.name; |
91 | | - }) |
92 | | - ( |
93 | | - let |
94 | | - entry = name: path: { inherit name path; }; |
95 | | - in |
96 | | - [ |
97 | | - (entry "config.toml" conf) |
98 | | - (entry "languages.toml" langs) |
99 | | - (entry "ignore" ignore) |
100 | | - ] |
101 | | - ++ themes |
102 | | - ) |
103 | | - ) |
| 56 | + themes = lib.mkOption { |
| 57 | + type = lib.types.attrsOf ( |
| 58 | + lib.types.oneOf [ |
| 59 | + tomlFmt.type |
| 60 | + lib.types.lines |
| 61 | + ] |
104 | 62 | ); |
| 63 | + description = '' |
| 64 | + Themes to add to config. |
| 65 | + See <https://docs.helix-editor.com/themes.html> |
| 66 | + ''; |
| 67 | + default = { }; |
| 68 | + }; |
| 69 | + ignores = lib.mkOption { |
| 70 | + type = lib.types.listOf lib.types.nonEmptyStr; |
| 71 | + default = [ ]; |
| 72 | + description = '' |
| 73 | + List of paths to be ignored by the file-picker. |
| 74 | + The format is the same as in .gitignore. |
| 75 | + ''; |
105 | 76 | }; |
106 | | - config.meta.maintainers = [ lib.maintainers.zimward ]; |
107 | | - } |
108 | | -) |
| 77 | + }; |
| 78 | + config.package = lib.mkDefault config.pkgs.helix; |
| 79 | + config.env = { |
| 80 | + XDG_CONFIG_HOME = builtins.toString ( |
| 81 | + config.pkgs.linkFarm "helix-merged-config" ( |
| 82 | + map |
| 83 | + (a: { |
| 84 | + inherit (a) path; |
| 85 | + name = "helix/" + a.name; |
| 86 | + }) |
| 87 | + ( |
| 88 | + let |
| 89 | + entry = name: path: { inherit name path; }; |
| 90 | + in |
| 91 | + [ |
| 92 | + (entry "config.toml" conf) |
| 93 | + (entry "languages.toml" langs) |
| 94 | + (entry "ignore" ignore) |
| 95 | + ] |
| 96 | + ++ themes |
| 97 | + ) |
| 98 | + ) |
| 99 | + ); |
| 100 | + }; |
| 101 | + config.meta.maintainers = [ lib.maintainers.zimward ]; |
| 102 | +} |
0 commit comments