2020-10-15 20:25:47 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.programs.gh;
|
|
|
|
|
2021-10-08 21:29:25 +00:00
|
|
|
yamlFormat = pkgs.formats.yaml { };
|
|
|
|
|
|
|
|
settingsType = types.submodule {
|
|
|
|
freeformType = yamlFormat.type;
|
|
|
|
# These options are only here for the mkRenamedOptionModule support
|
|
|
|
options = {
|
|
|
|
aliases = mkOption {
|
|
|
|
type = with types; attrsOf str;
|
|
|
|
default = { };
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2021-10-08 21:29:25 +00:00
|
|
|
{
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
git_protocol = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "https";
|
|
|
|
example = "ssh";
|
|
|
|
description = ''
|
|
|
|
The protocol to use when performing Git operations.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-10-15 20:25:47 +00:00
|
|
|
in {
|
2021-10-08 21:29:25 +00:00
|
|
|
meta.maintainers = [ maintainers.gerschtli maintainers.berbiche ];
|
|
|
|
|
|
|
|
imports = (map (x:
|
|
|
|
mkRenamedOptionModule [ "programs" "gh" x ] [
|
|
|
|
"programs"
|
|
|
|
"gh"
|
|
|
|
"settings"
|
|
|
|
x
|
|
|
|
]) [ "aliases" "editor" ]) ++ [
|
|
|
|
(mkRenamedOptionModule [ "programs" "gh" "gitProtocol" ] [
|
|
|
|
"programs"
|
|
|
|
"gh"
|
|
|
|
"settings"
|
|
|
|
"git_protocol"
|
|
|
|
])
|
|
|
|
];
|
2020-10-15 20:25:47 +00:00
|
|
|
|
|
|
|
options.programs.gh = {
|
|
|
|
enable = mkEnableOption "GitHub CLI tool";
|
|
|
|
|
2021-10-08 21:29:25 +00:00
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.gh;
|
2021-10-09 09:14:08 +00:00
|
|
|
defaultText = literalExpression "pkgs.gh";
|
2021-10-08 21:29:25 +00:00
|
|
|
description = "Package providing <command>gh</command>.";
|
|
|
|
};
|
|
|
|
|
|
|
|
settings = mkOption {
|
|
|
|
type = settingsType;
|
2020-10-15 20:25:47 +00:00
|
|
|
default = { };
|
2021-10-08 21:29:25 +00:00
|
|
|
description =
|
|
|
|
"Configuration written to <filename>$XDG_CONFIG_HOME/gh/config.yml</filename>.";
|
2021-10-09 09:14:08 +00:00
|
|
|
example = literalExpression ''
|
2020-10-15 20:25:47 +00:00
|
|
|
{
|
2021-10-08 21:29:25 +00:00
|
|
|
git_protocol = "ssh";
|
2020-10-15 20:25:47 +00:00
|
|
|
|
2021-10-08 21:29:25 +00:00
|
|
|
prompt = "enabled";
|
2020-10-15 20:25:47 +00:00
|
|
|
|
2021-10-08 21:29:25 +00:00
|
|
|
aliases = {
|
|
|
|
co = "pr checkout";
|
|
|
|
pv = "pr view";
|
|
|
|
};
|
|
|
|
};
|
2020-10-15 20:25:47 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2021-10-08 21:29:25 +00:00
|
|
|
home.packages = [ cfg.package ];
|
2020-10-15 20:25:47 +00:00
|
|
|
|
2021-10-08 21:29:25 +00:00
|
|
|
xdg.configFile."gh/config.yml".source =
|
|
|
|
yamlFormat.generate "gh-config.yml" cfg.settings;
|
2020-10-15 20:25:47 +00:00
|
|
|
};
|
|
|
|
}
|