fish: (NixOS only) source configuration sections anew in all child shells this fixes issue #25800: https://github.com/NixOS/nixpkgs/issues/25800

+13 -11
+13 -11
nixos/modules/programs/fish.nix
··· 104 104 environment.etc."fish/foreign-env/interactiveShellInit".text = cfge.interactiveShellInit; 105 105 106 106 environment.etc."fish/nixos-env-preinit.fish".text = '' 107 - # avoid clobbering the environment if it's been set by a parent shell 108 - 109 107 # This happens before $__fish_datadir/config.fish sets fish_function_path, so it is currently 110 108 # unset. We set it and then completely erase it, leaving its configuration to $__fish_datadir/config.fish 111 109 set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $__fish_datadir/functions ··· 120 118 environment.etc."fish/config.fish".text = '' 121 119 # /etc/fish/config.fish: DO NOT EDIT -- this file has been generated automatically. 122 120 123 - # if our parent shell didn't source the general config, do it 121 + # if we haven't sourced the general config, do it 124 122 if not set -q __fish_nixos_general_config_sourced 125 123 set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path 126 124 fenv source /etc/fish/foreign-env/shellInit > /dev/null ··· 128 126 129 127 ${cfg.shellInit} 130 128 131 - # and leave a note to our children to spare them the same work 132 - set -gx __fish_nixos_general_config_sourced 1 129 + # and leave a note so we don't source this config section again from 130 + # this very shell (children will source the general config anew) 131 + set -g __fish_nixos_general_config_sourced 1 133 132 end 134 133 135 - # if our parent shell didn't source the login config, do it 134 + # if we haven't sourced the login config, do it 136 135 status --is-login; and not set -q __fish_nixos_login_config_sourced 137 136 and begin 138 137 set fish_function_path ${pkgs.fish-foreign-env}/share/fish-foreign-env/functions $fish_function_path ··· 141 140 142 141 ${cfg.loginShellInit} 143 142 144 - # and leave a note to our children to spare them the same work 145 - set -gx __fish_nixos_login_config_sourced 1 143 + # and leave a note so we don't source this config section again from 144 + # this very shell (children will source the general config anew) 145 + set -g __fish_nixos_login_config_sourced 1 146 146 end 147 147 148 - # if our parent shell didn't source the interactive config, do it 148 + # if we haven't sourced the interactive config, do it 149 149 status --is-interactive; and not set -q __fish_nixos_interactive_config_sourced 150 150 and begin 151 151 ${fishAliases} ··· 158 158 ${cfg.promptInit} 159 159 ${cfg.interactiveShellInit} 160 160 161 - # and leave a note to our children to spare them the same work 162 - set -gx __fish_nixos_interactive_config_sourced 1 161 + # and leave a note so we don't source this config section again from 162 + # this very shell (children will source the general config anew, 163 + # allowing configuration changes in, e.g, aliases, to propagate) 164 + set -g __fish_nixos_interactive_config_sourced 1 163 165 end 164 166 ''; 165 167