diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 7def533a..fbe347cd 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1152,6 +1152,13 @@ in A new module is available: 'wayland.windowManager.hyprland' ''; } + + { + time = "2023-07-24T10:38:23+00:00"; + message = '' + A new module is available: 'programs.gh-dash' + ''; + } ]; }; } diff --git a/modules/modules.nix b/modules/modules.nix index 074efcb1..a23d6eba 100644 --- a/modules/modules.nix +++ b/modules/modules.nix @@ -87,6 +87,7 @@ let ./programs/gallery-dl.nix ./programs/getmail.nix ./programs/gh.nix + ./programs/gh-dash.nix ./programs/git-cliff.nix ./programs/git-credential-oauth.nix ./programs/git.nix diff --git a/modules/programs/gh-dash.nix b/modules/programs/gh-dash.nix new file mode 100644 index 00000000..69d5482b --- /dev/null +++ b/modules/programs/gh-dash.nix @@ -0,0 +1,42 @@ +{ config, lib, pkgs, ... }: + +let + + cfg = config.programs.gh-dash; + + yamlFormat = pkgs.formats.yaml { }; + +in { + meta.maintainers = [ lib.maintainers.janik ]; + + options.programs.gh-dash = { + enable = lib.mkEnableOption "GitHub CLI dashboard plugin"; + + package = lib.mkPackageOption pkgs "gh-dash" { }; + + settings = lib.mkOption { + type = yamlFormat.type; + default = { }; + example = lib.literalExpression '' + { + prSections = [{ + title = "My Pull Requests"; + filters = "is:open author:@me"; + }]; + } + ''; + description = '' + Configuration written to {file}`$XDG_CONFIG_HOME/gh-dash/config.yml`. + ''; + }; + }; + + config = lib.mkIf cfg.enable { + home.packages = [ cfg.package ]; + + programs.gh.extensions = [ cfg.package ]; + + xdg.configFile."gh-dash/config.yml".source = + yamlFormat.generate "gh-dash-config.yml" cfg.settings; + }; +} diff --git a/tests/default.nix b/tests/default.nix index e52d8d88..33331264 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -77,6 +77,7 @@ import nmt { ./modules/programs/fish ./modules/programs/gallery-dl ./modules/programs/gh + ./modules/programs/gh-dash ./modules/programs/git-cliff ./modules/programs/git ./modules/programs/gpg diff --git a/tests/modules/programs/gh-dash/config.nix b/tests/modules/programs/gh-dash/config.nix new file mode 100644 index 00000000..9972d673 --- /dev/null +++ b/tests/modules/programs/gh-dash/config.nix @@ -0,0 +1,26 @@ +{ ... }: + +{ + programs.gh-dash = { + enable = true; + settings = { + prSections = [{ + title = "My Pull Requests"; + filters = "is:open author:@me"; + }]; + }; + }; + + test.stubs.gh = { }; + + nmt.script = '' + assertFileExists home-files/.config/gh-dash/config.yml + assertFileContent home-files/.config/gh-dash/config.yml ${ + builtins.toFile "config-file.yml" '' + prSections: + - filters: is:open author:@me + title: My Pull Requests + '' + } + ''; +} diff --git a/tests/modules/programs/gh-dash/default.nix b/tests/modules/programs/gh-dash/default.nix new file mode 100644 index 00000000..16c22158 --- /dev/null +++ b/tests/modules/programs/gh-dash/default.nix @@ -0,0 +1 @@ +{ gh-dash-config = ./config.nix; }