summary refs log tree commit diff
path: root/pkgs/shells/fish
diff options
context:
space:
mode:
authorPatrick Callahan <pxcallahan@gmail.com>2017-05-16 12:17:43 -0700
committerPatrick Callahan <pxcallahan@gmail.com>2017-05-19 21:00:24 -0700
commit3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2 (patch)
tree6fe7d6412f2b738070bf376be6c5fcf7321fcbb8 /pkgs/shells/fish
parent9f6b1dca58375de995e8af4ae44ae76e3dd5f0f7 (diff)
downloadnixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar.gz
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar.bz2
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar.lz
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar.xz
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.tar.zst
nixpkgs-3f91e0dbae6ce0d37166084f4b8b93c46fe08ad2.zip
fish: source NixOS environment on non-login shells, when it hasn't been
sourced
(this fixes issue #25789:
https://github.com/NixOS/nixpkgs/issues/25789#issuecomment-301577290 and
the issue with git-annex mentioned here
https://github.com/NixOS/nixpkgs/pull/24314#issuecomment-301587124 )
Diffstat (limited to 'pkgs/shells/fish')
-rw-r--r--pkgs/shells/fish/default.nix7
1 files changed, 6 insertions, 1 deletions
diff --git a/pkgs/shells/fish/default.nix b/pkgs/shells/fish/default.nix
index 32b7694ba34..798d00b0be1 100644
--- a/pkgs/shells/fish/default.nix
+++ b/pkgs/shells/fish/default.nix
@@ -45,10 +45,15 @@ let
   '';
 
   fishPreInitHooks = ''
-    # source nixos environment if we're a login shell
+    # source nixos environment
+    # note that this is required:
+    #   1. For all shells, not just login shells (mosh needs this as do some other command-line utilities)
+    #   2. Before the shell is initialized, so that config snippets can find the commands they use on the PATH
     builtin status --is-login
+    or test -z "$__fish_nixos_env_preinit_sourced" -a -z "$ETC_PROFILE_SOURCED" -a -z "$ETC_ZSHENV_SOURCED"
     and test -f /etc/fish/nixos-env-preinit.fish
     and source /etc/fish/nixos-env-preinit.fish
+    and set -gx __fish_nixos_env_preinit_sourced 1
 
     test -n "$NIX_PROFILES"
     and begin