mirror of
https://github.com/nix-community/home-manager
synced 2024-11-27 05:29:46 +01:00
gh: add module
This commit is contained in:
parent
308ee310de
commit
22a3a5651d
7 changed files with 93 additions and 0 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -56,6 +56,9 @@
|
||||||
|
|
||||||
/modules/programs/firefox.nix @rycee
|
/modules/programs/firefox.nix @rycee
|
||||||
|
|
||||||
|
/modules/programs/gh.nix @Gerschtli
|
||||||
|
/tests/modules/programs/gh @Gerschtli
|
||||||
|
|
||||||
/modules/programs/git.nix @rycee
|
/modules/programs/git.nix @rycee
|
||||||
|
|
||||||
/modules/programs/gnome-terminal.nix @rycee
|
/modules/programs/gnome-terminal.nix @rycee
|
||||||
|
|
|
@ -1713,6 +1713,13 @@ in
|
||||||
A new module is available: 'services.gammastep'.
|
A new module is available: 'services.gammastep'.
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
time = "2020-10-22T21:30:42+00:00";
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'programs.gh'.
|
||||||
|
'';
|
||||||
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,7 @@ let
|
||||||
(loadModule ./programs/fish.nix { })
|
(loadModule ./programs/fish.nix { })
|
||||||
(loadModule ./programs/fzf.nix { })
|
(loadModule ./programs/fzf.nix { })
|
||||||
(loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; })
|
(loadModule ./programs/getmail.nix { condition = hostPlatform.isLinux; })
|
||||||
|
(loadModule ./programs/gh.nix { })
|
||||||
(loadModule ./programs/git.nix { })
|
(loadModule ./programs/git.nix { })
|
||||||
(loadModule ./programs/gnome-terminal.nix { })
|
(loadModule ./programs/gnome-terminal.nix { })
|
||||||
(loadModule ./programs/go.nix { })
|
(loadModule ./programs/go.nix { })
|
||||||
|
|
53
modules/programs/gh.nix
Normal file
53
modules/programs/gh.nix
Normal file
|
@ -0,0 +1,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.gitAndTools.gh ];
|
||||||
|
|
||||||
|
xdg.configFile."gh/config.yml".text =
|
||||||
|
builtins.toJSON { inherit (cfg) aliases editor gitProtocol; };
|
||||||
|
};
|
||||||
|
}
|
|
@ -48,6 +48,7 @@ import nmt {
|
||||||
./modules/programs/direnv
|
./modules/programs/direnv
|
||||||
./modules/programs/feh
|
./modules/programs/feh
|
||||||
./modules/programs/fish
|
./modules/programs/fish
|
||||||
|
./modules/programs/gh
|
||||||
./modules/programs/git
|
./modules/programs/git
|
||||||
./modules/programs/gpg
|
./modules/programs/gpg
|
||||||
./modules/programs/i3status
|
./modules/programs/i3status
|
||||||
|
|
27
tests/modules/programs/gh/config-file.nix
Normal file
27
tests/modules/programs/gh/config-file.nix
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
programs.gh = {
|
||||||
|
enable = true;
|
||||||
|
aliases = { co = "pr checkout"; };
|
||||||
|
editor = "vim";
|
||||||
|
};
|
||||||
|
|
||||||
|
nixpkgs.overlays = [
|
||||||
|
(self: super: {
|
||||||
|
gitAndTools = super.gitAndTools // {
|
||||||
|
gh = pkgs.writeScriptBin "dummy-gh" "";
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/gh/config.yml
|
||||||
|
assertFileContent home-files/.config/gh/config.yml ${
|
||||||
|
builtins.toFile "config-file.yml" ''
|
||||||
|
{"aliases":{"co":"pr checkout"},"editor":"vim","gitProtocol":"https"}''
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
1
tests/modules/programs/gh/default.nix
Normal file
1
tests/modules/programs/gh/default.nix
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{ gh-config-file = ./config-file.nix; }
|
Loading…
Reference in a new issue