1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/programs/scmpuff.nix
Austin Horstman 86402a17b6 treewide: flatten single file modules
Some files don't need nesting and can be root level again to reduce
conflicts with other PRs.

Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
2025-06-23 16:20:26 -05:00

63 lines
1.6 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
inherit (lib) mkIf;
cfg = config.programs.scmpuff;
in
{
meta.maintainers = [ lib.maintainers.cpcloud ];
options.programs.scmpuff = {
enable = lib.mkEnableOption ''
scmpuff, a command line tool that allows you to work quicker with Git by
substituting numeric shortcuts for files'';
package = lib.mkPackageOption pkgs "scmpuff" { };
enableBashIntegration = lib.hm.shell.mkBashIntegrationOption { inherit config; };
enableFishIntegration = lib.hm.shell.mkFishIntegrationOption { inherit config; };
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
enableAliases = lib.mkOption {
default = true;
type = lib.types.bool;
description = ''
Whether to enable aliases (e.g. gs, ga, gd, gco).
'';
};
};
config = mkIf cfg.enable (
let
mkArgs =
shell:
lib.concatStringsSep " " (
[ "--shell=${shell}" ] ++ lib.optional (!cfg.enableAliases) "--aliases=false"
);
in
{
home.packages = [ cfg.package ];
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "bash"})"
'';
programs.zsh.initContent = mkIf cfg.enableZshIntegration ''
eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "zsh"})"
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration (
lib.mkAfter ''
${cfg.package}/bin/scmpuff init ${mkArgs "fish"} | source
''
);
}
);
}