From 8675cfa549e1240c9d2abb1c878bc427eefcf926 Mon Sep 17 00:00:00 2001 From: amesgen Date: Wed, 27 Jul 2022 22:39:03 +0200 Subject: [PATCH] gh: add `extensions` option --- modules/programs/gh.nix | 16 ++++++++++++++ tests/modules/programs/gh/default.nix | 1 + tests/modules/programs/gh/extensions.nix | 27 ++++++++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 tests/modules/programs/gh/extensions.nix diff --git a/modules/programs/gh.nix b/modules/programs/gh.nix index ba457c8cb..920dd6438 100644 --- a/modules/programs/gh.nix +++ b/modules/programs/gh.nix @@ -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 . + ''; + 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); + }; }; } diff --git a/tests/modules/programs/gh/default.nix b/tests/modules/programs/gh/default.nix index c683b484e..d033ae22c 100644 --- a/tests/modules/programs/gh/default.nix +++ b/tests/modules/programs/gh/default.nix @@ -1,5 +1,6 @@ { gh-config-file = ./config-file.nix; gh-credential-helper = ./credential-helper.nix; + gh-extensions = ./extensions.nix; gh-warnings = ./warnings.nix; } diff --git a/tests/modules/programs/gh/extensions.nix b/tests/modules/programs/gh/extensions.nix new file mode 100644 index 000000000..c8824ed09 --- /dev/null +++ b/tests/modules/programs/gh/extensions.nix @@ -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" + ''; +}