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, ... }: {
deno-with-packages.lockfiles = [ ./deno.lock ];
deno-with-packages.dir = "$FLAKE_ROOT/.deno_cache";
devShells.default = pkgs.mkShell {
inputsFrom = [ config.flake-root.devShell ];

View file

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

View file

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