aboutsummaryrefslogtreecommitdiff
path: root/infra/libkookie/home-manager/modules/programs/gh.nix
blob: a4f4e17c9f63c4184c06aab3135cfe8cb36dc4bd (plain)
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
{ config, lib, pkgs, ... }:

with lib;

let

  cfg = config.programs.gh;

in {
  meta.maintainers = [ maintainers.gerschtli ];

  options.programs.gh = {
    enable = mkEnableOption "GitHub CLI tool";

    aliases = mkOption {
      type = with types; attrsOf str;
      default = { };
      example = literalExample ''
        {
          co = "pr checkout";
          pv = "pr view";
        }
      '';
      description = ''
        Aliases that allow you to create nicknames for gh commands.
      '';
    };

    editor = mkOption {
      type = types.str;
      default = "";
      description = ''
        The editor that gh should run when creating issues, pull requests, etc.
        If blank, will refer to environment.
      '';
    };

    gitProtocol = mkOption {
      type = types.enum [ "https" "ssh" ];
      default = "https";
      description = ''
        The protocol to use when performing Git operations.
      '';
    };
  };

  config = mkIf cfg.enable {
    home.packages = [ pkgs.gh ];

    xdg.configFile."gh/config.yml".text =
      builtins.toJSON { inherit (cfg) aliases editor gitProtocol; };
  };
}