all repos — nixfiles @ 66b709c399053cc91bc767317b8ae835f7666b71

System and user configuration, managed by nix and home-manager

dev/base: store direnv cache in $XDG_CACHE_HOME
Alan Pearce alan@alanpearce.eu
Wed, 12 Apr 2023 17:41:04 +0200
commit

66b709c399053cc91bc767317b8ae835f7666b71

parent

32a6944ea78623253aeedf9fc336c317f5e91eb7

1 files changed, 10 insertions(+), 0 deletions(-)

jump to
M user/settings/development/base.nixuser/settings/development/base.nix
@@ -47,4 +47,14 @@ };   programs.zsh.initExtra = ''
     source ${direnvHook}
   '';
+  xdg.configFile."direnv/direnvrc".text = ''
+    declare -A direnv_layout_dirs
+    direnv_layout_dir() {
+      echo "''${direnv_layout_dirs[$PWD]:=$(
+        local hash="$(${pkgs.coreutils}/bin/sha256sum - <<<"$\{PWD}" | cut -c-7)"
+    		local path="''${PWD//[^a-zA-Z0-9]/-}"
+        echo "${config.xdg.cacheHome}/direnv/layouts/''${hash}''${path}"
+      )}"
+    }
+  '';
 }