From 462d4a7abdfb8cb762584745a480ad01c207570e Mon Sep 17 00:00:00 2001 From: Mr Hedgehog Date: Thu, 20 Jan 2022 17:07:29 -0500 Subject: [PATCH] atuin: add fish integration --- modules/programs/atuin.nix | 14 +++++++++++++ tests/modules/programs/atuin/default.nix | 1 + tests/modules/programs/atuin/fish.nix | 25 +++++++++++++++++++++++ tests/modules/programs/atuin/no-shell.nix | 14 ++++++++++--- 4 files changed, 51 insertions(+), 3 deletions(-) create mode 100644 tests/modules/programs/atuin/fish.nix diff --git a/modules/programs/atuin.nix b/modules/programs/atuin.nix index 0e5fa071d..0d37854c0 100644 --- a/modules/programs/atuin.nix +++ b/modules/programs/atuin.nix @@ -40,6 +40,16 @@ in { ''; }; + enableFishIntegration = mkOption { + default = true; + type = types.bool; + description = '' + Whether to enable Atuin's Fish integration. + + If enabled, this will bind the up-arrow key to open the Atuin history. + ''; + }; + settings = mkOption { type = with types; let @@ -86,5 +96,9 @@ in { programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' eval "$(${cfg.package}/bin/atuin init zsh)" ''; + + programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' + ${cfg.package}/bin/atuin init fish | source + ''; }; } diff --git a/tests/modules/programs/atuin/default.nix b/tests/modules/programs/atuin/default.nix index 386a17288..ee22818a3 100644 --- a/tests/modules/programs/atuin/default.nix +++ b/tests/modules/programs/atuin/default.nix @@ -2,6 +2,7 @@ atuin-bash = ./bash.nix; atuin-empty-settings = ./empty-settings.nix; atuin-example-settings = ./example-settings.nix; + atuin-fish = ./fish.nix; atuin-no-shell = ./no-shell.nix; atuin-zsh = ./zsh.nix; } diff --git a/tests/modules/programs/atuin/fish.nix b/tests/modules/programs/atuin/fish.nix new file mode 100644 index 000000000..77232dbae --- /dev/null +++ b/tests/modules/programs/atuin/fish.nix @@ -0,0 +1,25 @@ +{ lib, ... }: + +{ + programs = { + atuin.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 = { + atuin = { }; + bash-preexec = { }; + fish = { }; + }; + + nmt.script = '' + assertFileExists home-files/.config/fish/config.fish + assertFileContains \ + home-files/.config/fish/config.fish \ + 'atuin init fish | source' + ''; +} diff --git a/tests/modules/programs/atuin/no-shell.nix b/tests/modules/programs/atuin/no-shell.nix index ef3bfe5d6..b636f7c0d 100644 --- a/tests/modules/programs/atuin/no-shell.nix +++ b/tests/modules/programs/atuin/no-shell.nix @@ -1,4 +1,4 @@ -{ ... }: +{ lib, ... }: { programs = { @@ -6,18 +6,26 @@ enable = true; enableBashIntegration = false; enableZshIntegration = false; + enableFishIntegration = false; }; bash.enable = true; zsh.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 = { atuin = { }; bash-preexec = { }; + fish = { }; }; nmt.script = '' - assertFileNotRegex home-files/.zshrc '@atuin@ init zsh' - assertFileNotRegex home-files/.bashrc '@atuin@ init bash' + assertFileNotRegex home-files/.zshrc 'atuin init zsh' + assertFileNotRegex home-files/.bashrc 'atuin init bash' + assertFileNotRegex home-files/.config/fish/config.fish 'atuin init fish' ''; }