1{
2 pkgs,
3 config,
4 lib,
5 ...
6}:
7
8let
9 cfg = config.programs.vivid;
10in
11{
12 options = {
13 programs.vivid = {
14 enable = lib.mkOption {
15 default = false;
16 description = "Whether to configure LS_COLORS with vivid.";
17 type = lib.types.bool;
18 };
19
20 package = lib.mkPackageOption pkgs "vivid" { example = "vivid"; };
21
22 theme = lib.mkOption {
23 default = "gruvbox-dark-soft";
24 description = "Theme to be used (see `vivid themes`)";
25 example = "solarized-dark";
26 type = lib.types.str;
27 };
28 };
29 };
30
31 config = lib.mkIf cfg.enable {
32 environment.systemPackages = [ cfg.package ];
33
34 programs =
35 let
36 interactiveShellInit = lib.mkAfter ''
37 export LS_COLORS="$(${lib.getExe cfg.package} generate ${cfg.theme})"
38 '';
39 enableLsColors = lib.mkOverride 999 false;
40 in
41 {
42 bash = {
43 inherit interactiveShellInit enableLsColors;
44 };
45 zsh = {
46 inherit interactiveShellInit enableLsColors;
47 };
48 };
49
50 assertions = [
51 {
52 assertion = !config.programs.bash.enableLsColors;
53 message = "`programs.vivid.enable` is incompatible with `programs.bash.enableLsColors`.";
54 }
55 {
56 assertion = !config.programs.zsh.enableLsColors;
57 message = "`programs.vivid.enable` is incompatible with `programs.zsh.enableLsColors`.";
58 }
59 ];
60 };
61
62 meta.maintainers = with lib.maintainers; [ gdifolco ];
63}