got conditional direnv loading working for zsh and bash

This commit is contained in:
Gerg-L 2023-06-26 19:22:20 -04:00
parent f43d0b741c
commit f2974e6b13
5 changed files with 29 additions and 19 deletions

4
flake.lock generated
View file

@ -290,8 +290,8 @@
]
},
"locked": {
"lastModified": 1687479458,
"narHash": "sha256-7ZeYakvK1Raz4oFwGrbcMbDe12nf9TXdXJvgp/e+N8Y=",
"lastModified": 1687747647,
"narHash": "sha256-1gkAQLFAnlzp2P55Wql8fV0o8dJjsosRtyEFSdxGj8k=",
"path": "/home/gerg/Projects/spicetify-nix",
"type": "path"
},

View file

@ -19,6 +19,7 @@
kmscon.enable = true;
};
};
boot.binfmt.emulatedSystems = ["aarch64-linux"];
hardware.nvidia = {
package = config.boot.kernelPackages.nvidiaPackages.beta;
nvidiaPersistenced = false;

View file

@ -6,8 +6,6 @@ in {
nixpkgs.allowedUnfree = ["spotify"];
programs.spicetify = {
enable = true;
spotifyPackage = spicePkgs.spotify;
spicetifyPackage = spicePkgs.spicetify-cli;
enabledExtensions = [
ex.adblock
ex.hidePodcasts

View file

@ -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
# '';
};
}

View file

@ -8,7 +8,6 @@ inputs: {pkgs, ...}: {
warn-dirty = false;
#ignore global registry
flake-registry = builtins.toFile "empty-flake-registry.json" ''{"flakes":[],"version":2}'';
use-xdg-base-directories = true;
#use for testing
#allow-import-from-derivation = false;
trusted-users = [
@ -17,6 +16,11 @@ inputs: {pkgs, ...}: {
];
allowed-users = [
];
use-xdg-base-directories = true;
};
};
#fix for use-xdg-base-directories
environment.profiles = [
"$HOME/.local/state/nix/profiles/profile"
];
}