nixos/home/modules/programs/fish.nix

63 lines
1.5 KiB
Nix
Raw Normal View History

2025-05-03 20:40:22 +08:00
{
config,
lib,
pkgs,
2025-05-03 20:40:22 +08:00
...
2025-07-13 06:04:55 +08:00
}:
let
2025-05-03 20:40:22 +08:00
cfg = config.youthlic.programs.fish;
2025-07-13 06:04:55 +08:00
in
{
2025-05-03 20:40:22 +08:00
options = {
youthlic.programs.fish = {
enable = lib.mkEnableOption "fish";
};
};
config = lib.mkIf cfg.enable {
programs = {
fish = {
enable = true;
preferAbbrs = true;
2025-05-03 20:40:22 +08:00
interactiveShellInit = ''
fish_vi_key_bindings
'';
plugins = [
{
name = with pkgs.fishPlugins.foreign-env; pname + "-" + version;
src = pkgs.fishPlugins.foreign-env.overrideAttrs {
postInstall = # bash
''
ln -s $out/share/fish/vendor_functions.d $out/functions
'';
};
}
];
2025-05-03 20:40:22 +08:00
functions = {
__fish_command_not_found_handler = {
body = "__fish_default_command_not_found_handler $argv[1]";
onEvent = "fish_command_not_found";
};
fish_greeting = {
body = ''
fastfetch
'';
};
};
shellInitLast = # fish
''
if test -d ~/.guix-profile
set -gx GUIX_PROFILE ~/.guix-profile
if test -f $GUIX_PROFILE/etc/profile
fenv source $GUIX_PROFILE/etc/profile
end
if test -d $GUIX_PROFILE/lib/locale
set -gx GUIX_LOCPATH $GUIX_PROFILE/lib/locale
end
end
'';
2025-05-03 20:40:22 +08:00
};
fastfetch.enable = true;
};
};
}