scmpuff: add fish integration flag

This commit is contained in:
Phillip Cloud 2022-08-22 05:38:58 -04:00 committed by Robert Helgesson
parent 3ce1c4787a
commit f7641a3ff3
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
4 changed files with 55 additions and 0 deletions

View file

@ -31,6 +31,14 @@ in {
Whether to enable Zsh integration.
'';
};
enableFishIntegration = mkOption {
default = true;
type = types.bool;
description = ''
Whether to enable fish integration.
'';
};
};
config = mkIf cfg.enable {
@ -43,5 +51,10 @@ in {
programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
eval "$(${cfg.package}/bin/scmpuff init -s)"
'';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration
(mkAfter ''
${cfg.package}/bin/scmpuff init -s --shell=fish | source
'');
};
}

View file

@ -4,4 +4,6 @@
scmpuff-no-shell = ./no-shell.nix;
scmpuff-no-zsh = ./no-zsh.nix;
scmpuff-zsh = ./zsh.nix;
scmpuff-fish = ./fish.nix;
scmpuff-no-fish = ./no-fish.nix;
}

View file

@ -0,0 +1,20 @@
{ pkgs, lib, ... }: {
programs = {
scmpuff.enable = true;
fish.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.fish = { };
test.stubs.scmpuff = { };
nmt.script = ''
assertFileExists home-files/.config/fish/config.fish
assertFileContains \
home-files/.config/fish/config.fish \
'@scmpuff@/bin/scmpuff init -s --shell=fish | source'
'';
}

View file

@ -0,0 +1,20 @@
{ pkgs, lib, ... }: {
programs = {
scmpuff = {
enable = true;
enableFishIntegration = false;
};
fish.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.fish = { };
test.stubs.scmpuff = { };
nmt.script = ''
assertFileNotRegex home-files/.config/fish/config.fish '@scmpuff@'
'';
}