From f7641a3ff398ccce952e19a199d775934e518c1d Mon Sep 17 00:00:00 2001 From: Phillip Cloud <417981+cpcloud@users.noreply.github.com> Date: Mon, 22 Aug 2022 05:38:58 -0400 Subject: [PATCH] scmpuff: add fish integration flag --- modules/programs/scmpuff.nix | 13 +++++++++++++ tests/modules/programs/scmpuff/default.nix | 2 ++ tests/modules/programs/scmpuff/fish.nix | 20 ++++++++++++++++++++ tests/modules/programs/scmpuff/no-fish.nix | 20 ++++++++++++++++++++ 4 files changed, 55 insertions(+) create mode 100644 tests/modules/programs/scmpuff/fish.nix create mode 100644 tests/modules/programs/scmpuff/no-fish.nix diff --git a/modules/programs/scmpuff.nix b/modules/programs/scmpuff.nix index 5f36ca02..0a573af0 100644 --- a/modules/programs/scmpuff.nix +++ b/modules/programs/scmpuff.nix @@ -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 + ''); }; } diff --git a/tests/modules/programs/scmpuff/default.nix b/tests/modules/programs/scmpuff/default.nix index 5852c5b6..bf162a9b 100644 --- a/tests/modules/programs/scmpuff/default.nix +++ b/tests/modules/programs/scmpuff/default.nix @@ -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; } diff --git a/tests/modules/programs/scmpuff/fish.nix b/tests/modules/programs/scmpuff/fish.nix new file mode 100644 index 00000000..f6abb1c7 --- /dev/null +++ b/tests/modules/programs/scmpuff/fish.nix @@ -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' + ''; +} diff --git a/tests/modules/programs/scmpuff/no-fish.nix b/tests/modules/programs/scmpuff/no-fish.nix new file mode 100644 index 00000000..d9f7e36f --- /dev/null +++ b/tests/modules/programs/scmpuff/no-fish.nix @@ -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@' + ''; +}