make cache dir configurable

This commit is contained in:
EatThePooh 2025-12-17 15:31:37 +07:00
parent e50afb2a22
commit 4cef3f1fd0
3 changed files with 5 additions and 7 deletions

View file

@ -20,6 +20,7 @@
perSystem = { config, pkgs, ... }: { perSystem = { config, pkgs, ... }: {
deno-with-packages.lockfiles = [ ./deno.lock ]; deno-with-packages.lockfiles = [ ./deno.lock ];
deno-with-packages.dir = "$FLAKE_ROOT/.deno_cache";
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
inputsFrom = [ config.flake-root.devShell ]; inputsFrom = [ config.flake-root.devShell ];

View file

@ -41,6 +41,7 @@ in
default = impl.denoWithCache { default = impl.denoWithCache {
baseDeno = config.deno-with-packages.basePackage; baseDeno = config.deno-with-packages.basePackage;
sharedCache = config.deno-with-packages.cache; sharedCache = config.deno-with-packages.cache;
dir = config.deno-with-packages.dir;
}; };
}; };

View file

@ -109,16 +109,12 @@ EOF
''; '';
denoWithCache = denoWithCache =
{ baseDeno, sharedCache }: { baseDeno, sharedCache, dir }:
pkgs.writeShellScriptBin "deno" '' pkgs.writeShellScriptBin "deno" ''
set -euo pipefail set -euo pipefail
if [ -n "''${FLAKE_ROOT:-}" ]; then # Use configured dir, with support for FLAKE_ROOT variable expansion
CACHE_DIR="$FLAKE_ROOT/.deno_cache" CACHE_DIR="${dir}"
else
echo "FLAKE_ROOT not set. Make sure you're using the flake-root devShell." >&2
exit 1
fi
if [ ! -d "$CACHE_DIR" ] || [ ! "$(ls -A "$CACHE_DIR" 2>/dev/null)" ]; then if [ ! -d "$CACHE_DIR" ] || [ ! "$(ls -A "$CACHE_DIR" 2>/dev/null)" ]; then
echo "Setting up Deno cache at: $CACHE_DIR" >&2 echo "Setting up Deno cache at: $CACHE_DIR" >&2