fork/home-manager

git clone https://git.julia.blue/fork/home-manager

Robert HelgessonMerge PR #421575790441

master
2.3 KiB86 linesraw
1{ config, lib, pkgs, ... }:
2
3with lib;
4
5let
6
7  cfg = config.programs.gitui;
8
9in {
10  meta.maintainers = [ hm.maintainers.mifom ];
11
12  options.programs.gitui = {
13    enable =
14      mkEnableOption "gitui, blazing fast terminal-ui for git written in rust";
15
16    package = mkOption {
17      type = types.package;
18      default = pkgs.gitui;
19      defaultText = "pkgs.gitui";
20      description = "The package to use.";
21    };
22
23    keyConfig = mkOption {
24      type = types.either types.path types.lines;
25      default = "";
26      example = ''
27        exit: Some(( code: Char('c'), modifiers: ( bits: 2,),)),
28        quit: Some(( code: Char('q'), modifiers: ( bits: 0,),)),
29        exit_popup: Some(( code: Esc, modifiers: ( bits: 0,),)),
30      '';
31      description = ''
32        Key config in Ron file format. This is written to
33        {file}`$XDG_CONFIG_HOME/gitui/key_config.ron`.
34      '';
35    };
36
37    theme = mkOption {
38      type = types.either types.path types.lines;
39      default = ''
40        (
41          selected_tab: Reset,
42          command_fg: White,
43          selection_bg: Blue,
44          selection_fg: White,
45          cmdbar_bg: Blue,
46          cmdbar_extra_lines_bg: Blue,
47          disabled_fg: DarkGray,
48          diff_line_add: Green,
49          diff_line_delete: Red,
50          diff_file_added: LightGreen,
51          diff_file_removed: LightRed,
52          diff_file_moved: LightMagenta,
53          diff_file_modified: Yellow,
54          commit_hash: Magenta,
55          commit_time: LightCyan,
56          commit_author: Green,
57          danger_fg: Red,
58          push_gauge_bg: Blue,
59          push_gauge_fg: Reset,
60          tag_fg: LightMagenta,
61          branch_fg: LightYellow,
62        )
63      '';
64      description = ''
65        Theme in Ron file format. This is written to
66        {file}`$XDG_CONFIG_HOME/gitui/theme.ron`.
67      '';
68    };
69  };
70
71  config = mkIf cfg.enable {
72    home.packages = [ cfg.package ];
73
74    xdg.configFile."gitui/theme.ron".source =
75      if builtins.isPath cfg.theme || lib.isStorePath cfg.theme then
76        cfg.theme
77      else
78        pkgs.writeText "gitui-theme.ron" cfg.theme;
79
80    xdg.configFile."gitui/key_bindings.ron".source =
81      if builtins.isPath cfg.keyConfig || lib.isStorePath cfg.keyConfig then
82        cfg.keyConfig
83      else
84        pkgs.writeText "gitui-key-config.ron" cfg.keyConfig;
85  };
86}