about summary refs log tree commit diff
path: root/modules/common/profiles/dev/sql.nix
blob: b290c1600751a894516126fec2b78795d431e79e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
{
  config,
  lib,
  pkgs,
  ...
}:
with lib; let
  cfg = config.nixfiles.modules.profiles.dev.sql;
in {
  options.nixfiles.modules.profiles.dev.sql.enable =
    mkEnableOption "SQL stuff and database management tools"
    // {
      default = config.nixfiles.modules.profiles.dev.enable;
    };

  config = mkIf cfg.enable {
    hm = {
      home.packages = with pkgs; [
        dbeaver
        pgcli
        litecli
      ];

      xdg = let
        mainSection = {
          destructive_warning = "True";
          enable_pager = "True";
          keyword_casing = "auto";
          less_chatty = "True";
          log_file = "/dev/null";
          log_level = "CRITICAL";
          multi_line = "False";
          syntax_style = "default";
          table_format = "fancy_grid";
        };

        colorsSection = with config.colourScheme; {
          "arg-toolbar" = "noinherit bold";
          "arg-toolbar.text" = "nobold";
          "bottom-toolbar" = "bg:${black} ${white}";
          "bottom-toolbar.off" = "bg:${black} ${brightBlack}";
          "bottom-toolbar.on" = "bg:${black} ${brightWhite}";
          "bottom-toolbar.transaction.failed" = "bg:${black} ${red} bold";
          "bottom-toolbar.transaction.valid" = "bg:${black} ${green} bold";
          "completion-menu.completion" = "bg:${black} ${white}";
          "completion-menu.completion.current" = "bg:${white} ${black}";
          "completion-menu.meta.completion" = "bg:${black} ${yellow}";
          "completion-menu.meta.completion.current" = "bg:${yellow} ${black}";
          "completion-menu.multi-column-meta" = "bg:${yellow} ${black}";
          "scrollbar" = "bg:${black}";
          "scrollbar.arrow" = "bg:${black}";
          "search" = "bg:${magenta} ${brightWhite}";
          "search-toolbar" = "noinherit bold";
          "search-toolbar.text" = "nobold";
          "search.current" = "bg:${green} ${brightWhite}";
          "selected" = "bg:${blue} ${brightWhite}";
          "system-toolbar" = "noinherit bold";
        };

        mkCliConfig = {
          name,
          custom,
        }: {
          "${name}/config" = {
            text = generators.toINI {} {
              main = mainSection // custom;
              colors = mapAttrs (_: v: "'${v}'") colorsSection;
            };
          };
        };
      in {
        configFile = mkMerge (map mkCliConfig [
          {
            name = "pgcli";
            custom = {
              prompt = "'\\u@\\h:\\d> '";
              multi_line_mode = "psql";
              on_error = "STOP";
              auto_expand = "True";
              expand = "True";
              keyring = "False";
              vi = "True";
              casing_file = "/dev/null";
              history_file = "/dev/null";
            };
          }
          {
            name = "litecli";
            custom = {
              prompt = "'\\d> '";
              prompt_continuation = "'-> '";
              auto_vertical_output = "True";
              key_bindings = "vi";
              audit_log = "/dev/null";
            };
          }
        ]);
      };
    };
  };
}

Consider giving Nix/NixOS a try! <3