2019-09-30 09:11:36 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
func = pkgs.writeText "func.fish" ''
|
|
|
|
function func
|
2022-12-05 02:51:03 +01:00
|
|
|
echo Hello
|
2019-09-30 09:11:36 +02:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
|
2020-03-01 22:20:44 +01:00
|
|
|
funcEvent = pkgs.writeText "func-event.fish" ''
|
|
|
|
function func-event --on-event="fish_command_not_found"
|
2022-12-05 02:51:03 +01:00
|
|
|
echo "Not found!"
|
2020-03-01 22:20:44 +01:00
|
|
|
end
|
|
|
|
'';
|
|
|
|
|
2019-09-30 09:11:36 +02:00
|
|
|
in {
|
|
|
|
config = {
|
|
|
|
programs.fish = {
|
|
|
|
enable = true;
|
|
|
|
|
2020-03-01 22:20:44 +01:00
|
|
|
functions = {
|
|
|
|
func = ''echo "Hello"'';
|
|
|
|
func-event = {
|
|
|
|
body = ''echo "Not found!"'';
|
|
|
|
onEvent = "fish_command_not_found";
|
|
|
|
};
|
|
|
|
};
|
2019-09-30 09:11:36 +02:00
|
|
|
};
|
|
|
|
|
2021-08-06 23:33:19 +02:00
|
|
|
# Needed to avoid error with dummy fish package.
|
|
|
|
xdg.dataFile."fish/home-manager_generated_completions".source =
|
|
|
|
lib.mkForce (builtins.toFile "empty" "");
|
|
|
|
|
2019-09-30 09:11:36 +02:00
|
|
|
nmt = {
|
|
|
|
description =
|
|
|
|
"if fish.function is set, check file exists and contents match";
|
|
|
|
script = ''
|
|
|
|
assertFileExists home-files/.config/fish/functions/func.fish
|
|
|
|
echo ${func}
|
|
|
|
assertFileContent home-files/.config/fish/functions/func.fish ${func}
|
2020-03-01 22:20:44 +01:00
|
|
|
|
|
|
|
assertFileExists home-files/.config/fish/functions/func-event.fish
|
|
|
|
echo ${funcEvent}
|
|
|
|
assertFileContent home-files/.config/fish/functions/func-event.fish ${funcEvent}
|
2019-09-30 09:11:36 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|