1

Modules/Fish: Add mechanism to load/unload fish environment shells with direnv

This commit is contained in:
2026-04-20 11:27:18 +02:00
parent f259b7d326
commit 2533183d80
7 changed files with 258 additions and 45 deletions

View File

@ -39,6 +39,7 @@
inputs.nixvim.homeModules.nixvim
inputs.textfox.homeManagerModules.default
inputs.walker.homeManagerModules.default
inputs.direnv-instant.homeModules.direnv-instant
# inputs.niri.homeModules.niri # Imported by system module
# inputs.noctalia.homeModules.default
# inputs.caelestia.homeManagerModules.default

View File

@ -87,6 +87,40 @@ in {
shellInit = ''
set fish_greeting
yes | fish_config theme save "system-theme"
# Because we can't source that in a project flake's shellHook (is POSIX), source it here
function __project_shell_reload --on-variable INIT_PROJECT_SHELL
# Leaving the environment
if not set -q INIT_PROJECT_SHELL; or test -z "$INIT_PROJECT_SHELL"
if test -n "$__last_unload_project_shell"; and test -f "$__last_unload_project_shell"
source "$__last_unload_project_shell"
end
set -e __last_init_project_shell
set -e __last_unload_project_shell
return
end
# Entering or switching environments
if test "$INIT_PROJECT_SHELL" != "$__last_init_project_shell"
# Cleanup the previous environment
if test -n "$__last_unload_project_shell"; and test -f "$__last_unload_project_shell"
source "$__last_unload_project_shell"
end
# Store into variables to persist until next environment switch in the same shell
set -g __last_init_project_shell "$INIT_PROJECT_SHELL"
if set -q UNLOAD_PROJECT_SHELL; and test -f "$UNLOAD_PROJECT_SHELL"
set -g __last_unload_project_shell "$UNLOAD_PROJECT_SHELL"
else
set -e __last_unload_project_shell
end
# Source the new environment
if test -f "$INIT_PROJECT_SHELL"
source "$INIT_PROJECT_SHELL"
end
end
end
'';
functions = lib.mergeAttrsList [

View File

@ -31,8 +31,8 @@ in {
settings = lib.mkMerge [
# Linux config
(lib.mkIf pkgs.stdenv.isLinux {
allow_remote_control = "yes"; # For nnn file preview or nvim scrollback
listen_on = "unix:@mykitty";
allow_remote_control = true; # For nnn file preview or nvim scrollback
listen_on = lib.mkDefault "unix:@mykitty"; # This conflicts with direnv-instant
})
# Common config

View File

@ -204,9 +204,19 @@ in {
direnv = {
enable = true;
enableFishIntegration = !config.programs.direnv-instant.enable;
silent = true;
nix-direnv.enable = true;
};
# This replaces the normal direnv.enableFishIntegration.
# direnv-instant = {
# enable = true;
# enableFishIntegration = true;
# enableKittyIntegration = true;
# settings.use_cache = true;
# };
eza = {
enable = true;
enableFishIntegration = config.homemodules.fish.enable;