Skip to content

Commit

Permalink
Configuration options for git-bubbles
Browse files Browse the repository at this point in the history
Fixes #45.
  • Loading branch information
ptitfred committed Oct 17, 2024
1 parent 56c5d31 commit 0a8795a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 3 deletions.
33 changes: 30 additions & 3 deletions home-manager-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
}
3 changes: 3 additions & 0 deletions tests/hm-module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}

0 comments on commit 0a8795a

Please sign in to comment.