mirror of
https://github.com/nix-community/home-manager
synced 2024-12-23 02:09:47 +01:00
gh: add extensions
option
This commit is contained in:
parent
78f964347c
commit
8675cfa549
3 changed files with 44 additions and 0 deletions
|
@ -95,6 +95,15 @@ in {
|
|||
mkEnableOption "the gh git credential helper for github.com" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
extensions = mkOption {
|
||||
type = types.listOf types.package;
|
||||
default = [ ];
|
||||
description = ''
|
||||
gh extensions, see <link xlink:href="https://cli.github.com/manual/gh_extension"/>.
|
||||
'';
|
||||
example = literalExpression "[ pkgs.gh-eco ]";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
@ -106,5 +115,12 @@ in {
|
|||
programs.git.extraConfig.credential."https://github.com".helper =
|
||||
mkIf cfg.enableGitCredentialHelper
|
||||
"${cfg.package}/bin/gh auth git-credential";
|
||||
|
||||
xdg.dataFile."gh/extensions" = mkIf (cfg.extensions != [ ]) {
|
||||
source = pkgs.linkFarm "gh-extensions" (builtins.map (p: {
|
||||
name = p.pname;
|
||||
path = "${p}/bin";
|
||||
}) cfg.extensions);
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
gh-config-file = ./config-file.nix;
|
||||
gh-credential-helper = ./credential-helper.nix;
|
||||
gh-extensions = ./extensions.nix;
|
||||
gh-warnings = ./warnings.nix;
|
||||
}
|
||||
|
|
27
tests/modules/programs/gh/extensions.nix
Normal file
27
tests/modules/programs/gh/extensions.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
programs.gh = {
|
||||
enable = true;
|
||||
extensions = [ pkgs.gh-eco ];
|
||||
};
|
||||
|
||||
test.stubs = {
|
||||
gh = { };
|
||||
gh-eco = {
|
||||
name = "gh-eco";
|
||||
buildScript = ''
|
||||
mkdir -p $out/bin
|
||||
touch $out/bin/gh-eco
|
||||
chmod +x $out/bin/gh-eco
|
||||
'';
|
||||
outPath = null;
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
gh_eco=home-files/.local/share/gh/extensions/gh-eco/gh-eco
|
||||
assertFileExists "$gh_eco"
|
||||
assertFileIsExecutable "$gh_eco"
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue