1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 11:19:47 +01:00

scmpuff: enable or disable aliases

This commit is contained in:
ilaumjd 2023-10-01 17:17:06 +07:00 committed by Mikilio
parent 9af726faca
commit 0e14af6788
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
8 changed files with 58 additions and 11 deletions

View file

@ -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
''); '');
}; });
} }

View file

@ -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)"'
''; '';
} }

View file

@ -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;
} }

View file

@ -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'
''; '';
} }

View 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'
'';
}

View file

@ -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@'
''; '';
} }

View file

@ -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@'
''; '';
} }

View file

@ -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)"'
''; '';
} }