Add direnv cache

Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
2024-12-15 19:09:07 +00:00
parent 08edfaa7dc
commit 239e44d704
2 changed files with 20 additions and 3 deletions

1
.envrc Normal file
View File

@@ -0,0 +1 @@
use flake self#nix

View File

@@ -4,14 +4,30 @@
}:
{ inputs, ... }:
{
home-manager.users.${user} = {
programs.direnv = {
home-manager.users.${user}.programs = {
direnv = {
enable = true;
silent = true;
nix-direnv.enable = true;
enableZshIntegration = true;
};
# https://github.com/direnv/direnv/wiki/Customizing-cache-location
zsh.initExtra = ''
declare -A direnv_layout_dirs
direnv_layout_dir() {
local hash path
echo "''${direnv_layout_dirs[$PWD]:=$(
hash="$(sha1sum - <<< "$PWD" | head -c40)"
path="''${PWD//[^a-zA-Z0-9]/-}"
echo "${home}/.cache/direnv/layouts/''${hash}''${path}"
)}"
}
'';
};
environment.persistence."/persist"."${home}/.config/direnv/direnv.toml" = { };
environment.persistence = {
"/persist"."${home}/.config/direnv/direnv.toml" = { };
"/cache"."${home}/.cache/direnv" = { };
};
}