From 4cef3f1fd0eabe8d0589c61952b965cfd369bffa Mon Sep 17 00:00:00 2001 From: EatThePooh Date: Wed, 17 Dec 2025 15:31:37 +0700 Subject: [PATCH] make cache dir configurable --- example/flake.nix | 1 + flake-module.nix | 1 + impl.nix | 10 +++------- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/example/flake.nix b/example/flake.nix index 393c0a4..5983e02 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -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 ]; diff --git a/flake-module.nix b/flake-module.nix index 2785aab..5e5d757 100644 --- a/flake-module.nix +++ b/flake-module.nix @@ -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; }; }; diff --git a/impl.nix b/impl.nix index 554a054..b95e9e4 100644 --- a/impl.nix +++ b/impl.nix @@ -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