From 1290e8ed9fc3b754a094c1e3915dd42f9ba2c830 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Mon, 26 Jan 2026 11:21:43 +0000 Subject: [PATCH] dashboard: fix prettier-svelte rebuilding on every file change The prettier-svelte package was rebuilding whenever any file in the repository changed because dashboardStubSrc referenced inputs.self directly. Since inputs.self's store path hash is computed from the entire repository contents, any file modification invalidated the derivation. Added dashboardLockfileSrc using lib.cleanSourceWith to filter inputs.self to only include package.json and package-lock.json from the dashboard directory. Updated dashboardStubSrc to reference this filtered source instead of inputs.self directly. This ensures prettier-svelte only rebuilds when the lockfiles actually change, significantly improving build caching for unrelated changes. Test plan: - Built prettier-svelte with nix build .#prettier-svelte - Modified src/exo/main.py and rebuilt - same store path (no rebuild) - Modified dashboard/package.json and rebuilt - different store path (rebuild triggered) - Ran nix flake check successfully --- dashboard/parts.nix | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/dashboard/parts.nix b/dashboard/parts.nix index 8edcc6b7..80df5c7e 100644 --- a/dashboard/parts.nix +++ b/dashboard/parts.nix @@ -3,12 +3,28 @@ perSystem = { pkgs, lib, ... }: let + # Filter source to ONLY include package.json and package-lock.json + # This ensures prettier-svelte only rebuilds when lockfiles change + dashboardLockfileSrc = lib.cleanSourceWith { + src = inputs.self; + filter = + path: type: + let + baseName = builtins.baseNameOf path; + isDashboardDir = baseName == "dashboard" && type == "directory"; + isPackageFile = + (lib.hasInfix "/dashboard/" path || lib.hasSuffix "/dashboard" (builtins.dirOf path)) + && (baseName == "package.json" || baseName == "package-lock.json"); + in + isDashboardDir || isPackageFile; + }; + # Stub source with lockfiles and minimal files for build to succeed # This allows prettier-svelte to avoid rebuilding when dashboard source changes dashboardStubSrc = pkgs.runCommand "dashboard-stub-src" { } '' mkdir -p $out - cp ${inputs.self}/dashboard/package.json $out/ - cp ${inputs.self}/dashboard/package-lock.json $out/ + cp ${dashboardLockfileSrc}/dashboard/package.json $out/ + cp ${dashboardLockfileSrc}/dashboard/package-lock.json $out/ # Minimal files so vite build succeeds (produces empty output) echo '' > $out/index.html mkdir -p $out/src