Skip to content

Commit

Permalink
Merge pull request #49 from ptitfred/git-bubbles-configuration
Browse files Browse the repository at this point in the history
Configuration options for git-bubbles
  • Loading branch information
ptitfred authored Oct 17, 2024
2 parents 56c5d31 + 22f14d6 commit d1c7014
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ The `your-home.nix` file might contain:
{
ptitfred.posix-toolbox.enable = true;
# Options for the git-bubbles script:
ptitfred.posix-toolbox.git-bubbles.remote-name = "some-remote-name";
ptitfred.posix-toolbox.git-bubbles.pattern = "---";
# You might have to enable git though:
programs.git.enable = true;
Expand Down
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;
};

mkOptionalStr = 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 = mkOptionalStr "remote-name";
pattern = mkOptionalStr "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 d1c7014

Please sign in to comment.