1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

gh: support gh as git credential manager for github.com

Co-authored-by: Sumner Evans <me@sumnerevans.com>
This commit is contained in:
Anselm Schüler 2021-10-19 06:43:52 +02:00 committed by Robert Helgesson
parent 3e4fedc1d9
commit cfe82d9f44
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 33 additions and 0 deletions

View file

@ -90,6 +90,11 @@ in {
};
'';
};
enableGitCredentialHelper =
mkEnableOption "the gh git credential helper for github.com" // {
default = true;
};
};
config = mkIf cfg.enable {
@ -97,5 +102,9 @@ in {
xdg.configFile."gh/config.yml".source =
yamlFormat.generate "gh-config.yml" cfg.settings;
programs.git.extraConfig.credential."https://github.com".helper =
mkIf cfg.enableGitCredentialHelper
"${cfg.package}/bin/gh auth git-credential";
};
}

View file

@ -0,0 +1,2 @@
[credential "https://github.com"]
helper = "@gh@/bin/gh auth git-credential"

View file

@ -0,0 +1,21 @@
{ config, lib, pkgs, ... }:
{
programs.gh = {
enable = true;
enableGitCredentialHelper = true;
};
programs.git.enable = true;
test.stubs = {
gh = { };
git = { };
};
nmt.script = ''
assertFileExists home-files/.config/git/config
assertFileContent home-files/.config/git/config \
${./credential-helper.git.conf}
'';
}

View file

@ -1,4 +1,5 @@
{
gh-config-file = ./config-file.nix;
gh-credential-helper = ./credential-helper.nix;
gh-warnings = ./warnings.nix;
}