Skip to content

Commit 616a22a

Browse files
authored
feat(wrapperModules.aerc): init (#492)
1 parent a3b7614 commit 616a22a

1 file changed

Lines changed: 96 additions & 0 deletions

File tree

wrapperModules/a/aerc/module.nix

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
{
2+
config,
3+
lib,
4+
wlib,
5+
pkgs,
6+
...
7+
}:
8+
let
9+
iniFmt = pkgs.formats.ini { };
10+
iniWithGlobalFmt = pkgs.formats.iniWithGlobalSection { };
11+
in
12+
{
13+
imports = [ wlib.modules.default ];
14+
options = {
15+
settings = lib.mkOption {
16+
type = iniFmt.type;
17+
default = { };
18+
description = ''
19+
Aerc main configuration file.
20+
See {manpage}`aerc-config(5)`
21+
'';
22+
};
23+
keybinds = lib.mkOption {
24+
type = iniWithGlobalFmt.type;
25+
default = { };
26+
description = ''
27+
Aerc keybinds configuration file.
28+
See {manpage}`aerc-binds(5)`
29+
'';
30+
};
31+
accounts = lib.mkOption {
32+
type = iniFmt.type;
33+
default = { };
34+
description = ''
35+
Aerc accounts configuration file.
36+
Should not contain any plaintext secrets, as it's copied to nix store.
37+
Use `outgoing-cred-cmd` and `source-cred-cmd` instead.
38+
See {manpage}`aerc-accounts(5)`
39+
'';
40+
};
41+
stylesets = lib.mkOption {
42+
type = lib.types.attrsOf iniWithGlobalFmt.type;
43+
default = { };
44+
description = ''
45+
Stylesets (themes) for aerc.
46+
See {manpage}`aerc-stylesets(5)`
47+
'';
48+
};
49+
};
50+
config =
51+
let
52+
stylesets-content = lib.mapAttrs (
53+
name: value: lib.generators.toINIWithGlobalSection { } value
54+
) config.stylesets;
55+
stylesets-constructFiles = lib.concatMapAttrs (name: value: {
56+
"stylesets-${name}" = {
57+
content = value;
58+
relPath = "stylesets/${name}";
59+
};
60+
}) stylesets-content;
61+
stylesets-dir = "${placeholder "out"}/stylesets";
62+
aerc-config =
63+
if config.settings ? ui && config.settings.ui ? stylesets-dirs then
64+
lib.recursiveUpdate config.settings {
65+
ui.stylesets-dirs = "${config.settings.ui.stylesets-dirs},${stylesets-dir}";
66+
}
67+
else
68+
lib.recursiveUpdate config.settings {
69+
ui.stylesets-dirs = stylesets-dir;
70+
};
71+
in
72+
{
73+
constructFiles = {
74+
aercConfig = {
75+
content = lib.generators.toINI { } aerc-config;
76+
relPath = "${config.binName}.conf";
77+
};
78+
keybindsConfig = {
79+
content = lib.generators.toINIWithGlobalSection { } config.keybinds;
80+
relPath = "${config.binName}-keybinds.conf";
81+
};
82+
accountsConfig = {
83+
content = lib.generators.toINI { } config.accounts;
84+
relPath = "${config.binName}-accounts.conf";
85+
};
86+
}
87+
// stylesets-constructFiles;
88+
flags = {
89+
"--aerc-conf" = config.constructFiles.aercConfig.path;
90+
"--binds-conf" = config.constructFiles.keybindsConfig.path;
91+
"--accounts-conf" = config.constructFiles.accountsConfig.path;
92+
};
93+
package = lib.mkDefault pkgs.aerc;
94+
meta.maintainers = [ wlib.maintainers.appleptree ];
95+
};
96+
}

0 commit comments

Comments
 (0)