mirror of
https://github.com/Gerg-L/nixos.git
synced 2025-12-10 00:43:56 -05:00
got conditional direnv loading working for zsh and bash
This commit is contained in:
parent
f43d0b741c
commit
f2974e6b13
5 changed files with 29 additions and 19 deletions
|
|
@ -1,27 +1,34 @@
|
|||
_: {pkgs, ...}: {
|
||||
environment = {
|
||||
systemPackages = builtins.attrValues {
|
||||
inherit
|
||||
(pkgs)
|
||||
nix-direnv
|
||||
direnv
|
||||
;
|
||||
};
|
||||
|
||||
systemPackages = [pkgs.direnv];
|
||||
variables = {
|
||||
DIRENV_LOG_FORMAT = "";
|
||||
DIRENV_CONFIG = "${pkgs.nix-direnv}/share/nix-direnv";
|
||||
DIRENV_CONFIG = "/etc/direnv";
|
||||
};
|
||||
etc."direnv/direnvrc".text = ''
|
||||
source ${pkgs.nix-direnv}/share/nix-direnv/direnvrc
|
||||
if [ -e $HOME/.config/direnv/direnvrc ] ; then
|
||||
source $HOME/.config/direnv/direnvrc
|
||||
fi
|
||||
'';
|
||||
};
|
||||
programs = {
|
||||
zsh.interactiveShellInit = ''
|
||||
eval "$(direnv hook zsh)"
|
||||
if [[ -o interactive ]] && ! printenv PATH | grep -qc '/nix/store' && [ -z "$IN_NIX_SHELL" ] ; then
|
||||
eval "$(direnv hook zsh)"
|
||||
fi
|
||||
'';
|
||||
bash.interactiveShellInit = ''
|
||||
eval "$(direnv hook bash)"
|
||||
'';
|
||||
fish.interactiveShellInit = ''
|
||||
direnv hook fish | source
|
||||
if [ $- == *i* ] && ! printenv PATH | grep -qc '/nix/store' && [ -z "$IN_NIX_SHELL" ] ; then
|
||||
eval "$(direnv hook bash)"
|
||||
fi
|
||||
'';
|
||||
# fish.enable = true;
|
||||
# fish.interactiveShellInit = ''
|
||||
# if status --is-interactive; and not printenv PATH | grep -qc '/nix/store'; and [ -z "$IN_NIX_SHELL" ];
|
||||
# direnv hook fish | source;
|
||||
# echo "loaded direnv";
|
||||
# end
|
||||
# '';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue