mirror of
https://github.com/nix-community/home-manager
synced 2024-11-20 10:09:45 +01:00
scmpuff: enable or disable aliases
This commit is contained in:
parent
6f9b5b83ad
commit
55ce64c3ca
8 changed files with 58 additions and 11 deletions
|
@ -39,22 +39,34 @@ in {
|
||||||
Whether to enable fish integration.
|
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 ];
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
|
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 ''
|
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
|
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
|
||||||
(mkAfter ''
|
(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
|
assertFileExists home-files/.bashrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.bashrc \
|
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-zsh = ./zsh.nix;
|
||||||
scmpuff-fish = ./fish.nix;
|
scmpuff-fish = ./fish.nix;
|
||||||
scmpuff-no-fish = ./no-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
|
assertFileExists home-files/.config/fish/config.fish
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.config/fish/config.fish \
|
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 = { };
|
test.stubs.scmpuff = { };
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileNotRegex home-files/.bashrc '@scmpuff@/bin/scmpuff'
|
assertFileNotRegex home-files/.bashrc '@scmpuff@'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
nmt.script = ''
|
nmt.script = ''
|
||||||
assertFileNotRegex home-files/.zshrc '@scmpuff@ init -s'
|
assertFileNotRegex home-files/.zshrc '@scmpuff@'
|
||||||
assertFileNotRegex home-files/.bashrc '@scmpuff@ init -s'
|
assertFileNotRegex home-files/.bashrc '@scmpuff@'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,6 @@
|
||||||
assertFileExists home-files/.zshrc
|
assertFileExists home-files/.zshrc
|
||||||
assertFileContains \
|
assertFileContains \
|
||||||
home-files/.zshrc \
|
home-files/.zshrc \
|
||||||
'eval "$(@scmpuff@/bin/scmpuff init -s)"'
|
'eval "$(@scmpuff@/bin/scmpuff init --shell=zsh)"'
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue