34 lines
850 B
Nix
34 lines
850 B
Nix
{
|
|
user ? throw "user argument is required",
|
|
home ? throw "home argument is required",
|
|
}:
|
|
{ inputs, ... }:
|
|
{
|
|
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" = { };
|
|
"/cache"."${home}/.cache/direnv" = { };
|
|
};
|
|
}
|