diff --git a/home-manager-module.nix b/home-manager-module.nix index 1d4aa0a..6cbf368 100644 --- a/home-manager-module.nix +++ b/home-manager-module.nix @@ -22,21 +22,48 @@ let cfg = config.ptitfred.posix-toolbox; lib.strings.optionalString config.programs.git.enable "source ${posix-toolbox.git-ps1}/share/posix-toolbox/git-ps1"; - initExtra = + bashInitExtra = '' ${gitBashInitExtra} source ${posix-toolbox.ls-colors}/share/ls-colors/bash.sh ''; + + gitExtraConfig = { + bubbles = lib.attrsets.filterAttrs (_: value: ! (isNull value)) cfg.git-bubbles; + }; + + mkOptionalString = description: + lib.mkOption { + inherit description; + type = lib.types.nullOr lib.types.str; + default = null; + }; in { options = { - ptitfred.posix-toolbox.enable = lib.mkEnableOption "posix-toolbox"; + ptitfred.posix-toolbox = { + enable = lib.mkEnableOption "posix-toolbox"; + + git-bubbles = lib.mkOption { + description = "options for git-bubbles"; + default = {}; + type = (lib.types.submodule { + options = { + remote-name = mkOptionalString "remote-name"; + pattern = mkOptionalString "pattern"; + }; + }); + }; + }; }; config = { home.packages = lib.mkIf cfg.enable packages; programs.bash.initExtra = - lib.mkIf (cfg.enable && config.programs.bash.enable) initExtra; + lib.mkIf (cfg.enable && config.programs.bash.enable) bashInitExtra; + + programs.git.extraConfig = + lib.mkIf (cfg.enable && config.programs.git.enable) gitExtraConfig; }; } diff --git a/tests/hm-module.nix b/tests/hm-module.nix index 72703e7..f7fe1ad 100644 --- a/tests/hm-module.nix +++ b/tests/hm-module.nix @@ -14,4 +14,7 @@ # This is how you enable posix-toolbox features (depends on bash and git being active): ptitfred.posix-toolbox.enable = true; + + # Example configuration for git-bubbles: + ptitfred.posix-toolbox.git-bubbles.remote-name = "mine"; }