chore: small fixes

This commit is contained in:
xinyangli 2024-08-20 21:09:31 +08:00
parent ed19829fe4
commit 27901b05c6
Signed by: xin
SSH key fingerprint: SHA256:qZ/tzd8lYRtUFSrfBDBMcUqV4GHKxqeqRA3huItgvbk
5 changed files with 52 additions and 12 deletions

View file

@ -1,18 +1,30 @@
{ config, lib, ... }:
{ config, lib, ... }:
with lib;
let
cfg = config.custom-hm.direnv;
changeCacheDir = ''
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 "''${XDG_CACHE_HOME}/direnv/layouts/''${hash}''${path}"
)}"
}
'';
in
{
options.custom-hm.direnv = {
enable = mkEnableOption "direnv";
};
config = {
programs = mkIf config.custom-hm.direnv.enable {
programs = mkIf cfg.enable {
direnv = {
enable = true;
stdlib = changeCacheDir;
};
};
};
}
}