From 0482a66a21932c46f116205e0923f2f2bc866e41 Mon Sep 17 00:00:00 2001 From: Tomo <68489118+Tomodachi94@users.noreply.github.com> Date: Tue, 9 Apr 2024 18:15:33 -0700 Subject: [PATCH] git-credential-oauth: add extraFlags option This facilitates a legitimate use-case for browserless systems. From the README: > On systems without a web browser, set the -device flag to authenticate > on another device using [OAuth device flow]: > ```ini [credential] helper = cache --timeout 7200 # two hours helper = oauth -device ``` [OAuth device flow]: https://www.rfc-editor.org/rfc/rfc8628 Please note that, for the documentation about the man-page to be accurate, https://github.com/NixOS/nixpkgs/pull/302922 must be merged. --- modules/programs/git-credential-oauth.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/modules/programs/git-credential-oauth.nix b/modules/programs/git-credential-oauth.nix index 4833e806..1f4b9924 100644 --- a/modules/programs/git-credential-oauth.nix +++ b/modules/programs/git-credential-oauth.nix @@ -12,13 +12,26 @@ in { enable = lib.mkEnableOption "Git authentication handler for OAuth"; package = lib.mkPackageOption pkgs "git-credential-oauth" { }; + + extraFlags = lib.mkOption { + type = lib.types.listOf lib.types.str; + default = [ ]; + example = lib.literalExpression ''[ "-device" ]''; + description = '' + Extra command-line arguments passed to git-credential-oauth. + + For valid arguments, see {manpage}`git-credential-oauth(1)`. + ''; + }; }; }; config = lib.mkIf cfg.enable { home.packages = [ cfg.package ]; - programs.git.extraConfig.credential.helper = - [ "${cfg.package}/bin/git-credential-oauth" ]; + programs.git.extraConfig.credential.helper = [ + ("${cfg.package}/bin/git-credential-oauth" + lib.mkIf cfg.extraFlags + " ${lib.strings.concatStringsSep " " cfg.extraFlags}") + ]; }; }