scmpuff: enable or disable aliases
This commit is contained in:
parent
6f9b5b83ad
commit
55ce64c3ca
|
@ -39,22 +39,34 @@ in {
|
|||
Whether to enable fish integration.
|
||||
'';
|
||||
};
|
||||
|
||||
enableAliases = mkOption {
|
||||
default = true;
|
||||
type = types.bool;
|
||||
description = ''
|
||||
Whether to enable aliases (e.g. gs, ga, gd, gco).
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf cfg.enable (let
|
||||
mkArgs = shell:
|
||||
concatStringsSep " " ([ "--shell=${shell}" ]
|
||||
++ optional (!cfg.enableAliases) "--aliases=false");
|
||||
in {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
||||
eval "$(${cfg.package}/bin/scmpuff init -s)"
|
||||
eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "bash"})"
|
||||
'';
|
||||
|
||||
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
eval "$(${cfg.package}/bin/scmpuff init -s)"
|
||||
eval "$(${cfg.package}/bin/scmpuff init ${mkArgs "zsh"})"
|
||||
'';
|
||||
|
||||
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
|
||||
(mkAfter ''
|
||||
${cfg.package}/bin/scmpuff init -s --shell=fish | source
|
||||
${cfg.package}/bin/scmpuff init ${mkArgs "fish"} | source
|
||||
'');
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
|
@ -12,6 +12,6 @@
|
|||
assertFileExists home-files/.bashrc
|
||||
assertFileContains \
|
||||
home-files/.bashrc \
|
||||
'eval "$(@scmpuff@/bin/scmpuff init -s)"'
|
||||
'eval "$(@scmpuff@/bin/scmpuff init --shell=bash)"'
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -6,4 +6,5 @@
|
|||
scmpuff-zsh = ./zsh.nix;
|
||||
scmpuff-fish = ./fish.nix;
|
||||
scmpuff-no-fish = ./no-fish.nix;
|
||||
scmpuff-no-aliases = ./no-aliases.nix;
|
||||
}
|
||||
|
|
|
@ -16,6 +16,6 @@
|
|||
assertFileExists home-files/.config/fish/config.fish
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'@scmpuff@/bin/scmpuff init -s --shell=fish | source'
|
||||
'@scmpuff@/bin/scmpuff init --shell=fish | source'
|
||||
'';
|
||||
}
|
||||
|
|
34
tests/modules/programs/scmpuff/no-aliases.nix
Normal file
34
tests/modules/programs/scmpuff/no-aliases.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{ lib, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
scmpuff.enable = true;
|
||||
scmpuff.enableAliases = false;
|
||||
bash.enable = true;
|
||||
fish.enable = true;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
# Needed to avoid error with dummy fish package.
|
||||
xdg.dataFile."fish/home-manager_generated_completions".source =
|
||||
lib.mkForce (builtins.toFile "empty" "");
|
||||
|
||||
test.stubs.scmpuff = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileExists home-files/.bashrc
|
||||
assertFileContains \
|
||||
home-files/.bashrc \
|
||||
'eval "$(@scmpuff@/bin/scmpuff init --shell=bash --aliases=false)"'
|
||||
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'eval "$(@scmpuff@/bin/scmpuff init --shell=zsh --aliases=false)"'
|
||||
|
||||
assertFileExists home-files/.config/fish/config.fish
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'@scmpuff@/bin/scmpuff init --shell=fish --aliases=false | source'
|
||||
'';
|
||||
}
|
|
@ -12,6 +12,6 @@
|
|||
test.stubs.scmpuff = { };
|
||||
|
||||
nmt.script = ''
|
||||
assertFileNotRegex home-files/.bashrc '@scmpuff@/bin/scmpuff'
|
||||
assertFileNotRegex home-files/.bashrc '@scmpuff@'
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileNotRegex home-files/.zshrc '@scmpuff@ init -s'
|
||||
assertFileNotRegex home-files/.bashrc '@scmpuff@ init -s'
|
||||
assertFileNotRegex home-files/.zshrc '@scmpuff@'
|
||||
assertFileNotRegex home-files/.bashrc '@scmpuff@'
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -15,6 +15,6 @@
|
|||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'eval "$(@scmpuff@/bin/scmpuff init -s)"'
|
||||
'eval "$(@scmpuff@/bin/scmpuff init --shell=zsh)"'
|
||||
'';
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue