From 82366f71341bee2ad232429deea6e05da94aed5e Mon Sep 17 00:00:00 2001 From: LGUG2Z Date: Thu, 5 Nov 2026 16:43:37 -0800 Subject: [PATCH] fix(nix): evaluation no longer reads store paths that builtins.path makes nix flake check --no-build failed in the nix-eval job on the runner with "path ...-Cargo.lock is not valid": crane's vendorCargoDeps runs pathExists on the lock at evaluation time, and `repoFile` is a store path that builtins.path makes during evaluation. Nix 2.35 with an empty store, as on a fresh runner, does not have it yet under --no-build; Lix, and a store that had seen the file, do. The parsed lock now comes from the flake source (cargoLockParsed in nix/lib.nix), and the Windows guest reads tools/test-partition.json the same way. The derivations are unchanged (same drv paths), so no cache key moves. Reproduced and fixed with upstream Nix and an empty store: nix shell nixpkgs#nixVersions.latest -c nix flake check --no-build --all-systems --store --- nix/lib.nix | 8 ++++++++ nix/linux/build.nix | 5 ++++- nix/macos/build.nix | 5 ++++- nix/nixgen/build.nix | 5 ++++- nix/recorder/build.nix | 5 ++++- nix/windows/build.nix | 5 ++++- nix/windows/flake-module.nix | 2 +- 7 files changed, 29 insertions(+), 6 deletions(-) diff --git a/nix/lib.nix b/nix/lib.nix index 932d637a..b1af0163 100644 --- a/nix/lib.nix +++ b/nix/lib.nix @@ -14,6 +14,14 @@ rec { name = builtins.baseNameOf rel; }; + # The lock, parsed at evaluation from the source of the flake itself. crane's `vendorCargoDeps` reads the lock it is + # given while evaluating (`pathExists`, `readFile`), and `repoFile` above is a store path that `builtins.path` makes + # during evaluation: Nix 2.35 on a runner whose store is empty does not have it there yet under + # `nix flake check --no-build` ("path ... is not valid"), though Lix and a store that has seen it do. The + # parsed lock is handed to `vendorCargoDeps` next to `cargoLock = repoFile "Cargo.lock"`, which is still what + # the derivations name, so that an edit of any other file does not change them. + cargoLockParsed = builtins.fromTOML (builtins.readFile (repoRoot + "/Cargo.lock")); + # the version of the workspace: every package says `version.workspace = true` version = (builtins.fromTOML (builtins.readFile (repoRoot + "/Cargo.toml"))).workspace.package.version; diff --git a/nix/linux/build.nix b/nix/linux/build.nix index 018edb0c..d542835e 100644 --- a/nix/linux/build.nix +++ b/nix/linux/build.nix @@ -35,7 +35,10 @@ in # would then change the dependencies cargoLock = lockFile; cargoToml = tomlFile; - cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; }; + cargoVendorDir = craneLib.vendorCargoDeps { + cargoLock = lockFile; + inherit (lib') cargoLockParsed; + }; }; commonArgs = workspaceArgs // { diff --git a/nix/macos/build.nix b/nix/macos/build.nix index 58287da3..f5a4ebcd 100644 --- a/nix/macos/build.nix +++ b/nix/macos/build.nix @@ -35,7 +35,10 @@ in # would then change the dependencies cargoLock = lockFile; cargoToml = tomlFile; - cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; }; + cargoVendorDir = craneLib.vendorCargoDeps { + cargoLock = lockFile; + inherit (lib') cargoLockParsed; + }; }; commonArgs = workspaceArgs // { diff --git a/nix/nixgen/build.nix b/nix/nixgen/build.nix index 4f35a046..48941cee 100644 --- a/nix/nixgen/build.nix +++ b/nix/nixgen/build.nix @@ -36,7 +36,10 @@ in # would then change the dependencies cargoLock = lockFile; cargoToml = tomlFile; - cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; }; + cargoVendorDir = craneLib.vendorCargoDeps { + cargoLock = lockFile; + inherit (lib') cargoLockParsed; + }; strictDeps = true; }; diff --git a/nix/recorder/build.nix b/nix/recorder/build.nix index 0046b1e0..cbb5d4cd 100644 --- a/nix/recorder/build.nix +++ b/nix/recorder/build.nix @@ -38,7 +38,10 @@ in # would then change the dependencies cargoLock = lockFile; cargoToml = tomlFile; - cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; }; + cargoVendorDir = craneLib.vendorCargoDeps { + cargoLock = lockFile; + inherit (lib') cargoLockParsed; + }; strictDeps = true; # the commit of the komorebi source the build script indexes: a constant, so that the # dependencies and every check are the same derivations for every commit; only the build diff --git a/nix/windows/build.nix b/nix/windows/build.nix index 2ba7737f..f6aa44b6 100644 --- a/nix/windows/build.nix +++ b/nix/windows/build.nix @@ -181,7 +181,10 @@ let # would change the dependencies cargoLock = lockFile; cargoToml = tomlFile; - cargoVendorDir = craneLib.vendorCargoDeps { cargoLock = lockFile; }; + cargoVendorDir = craneLib.vendorCargoDeps { + cargoLock = lockFile; + inherit (lib') cargoLockParsed; + }; }; commonArgs = workspaceArgs // { diff --git a/nix/windows/flake-module.nix b/nix/windows/flake-module.nix index c801427c..aced222c 100644 --- a/nix/windows/flake-module.nix +++ b/nix/windows/flake-module.nix @@ -65,7 +65,7 @@ in # the packages whose tests the guest runs by default: the partition (tools/test-partition.json, the # one list of which package is tested where) says which are the Windows ones, and which are neutral # but depend on the OS (sockets, pipes, paths, the registry). The neutral ones run on Linux. - partition = builtins.fromJSON (builtins.readFile (lib'.repoFile "tools/test-partition.json")); + partition = builtins.fromJSON (builtins.readFile (lib'.repoRoot + "/tools/test-partition.json")); windowsPackages = partition.windows ++ partition.os_sensitive; selected = pkgs.lib.concatMapStringsSep " " (p: "-p ${p}") windowsPackages; # the members that are stubs here (the Linux and macOS packages) have no test and do not build