Files
komorebi/nix/nixgen/build.nix
T
LGUG2Z 82366f7134 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 <empty dir>
2026-11-05 16:48:10 -08:00

75 lines
2.3 KiB
Nix

# The crane derivations of schemars-nixgen, the tool that writes the Nix options of the modules from the JSON
# Schemas, from the one Cargo workspace (nix/workspace-src.nix, platform "nixgen": the tool and nothing
# else). It is pure Rust, so one build serves every system.
{ inputs }:
let
lib' = import ../lib.nix { inherit inputs; };
inherit (inputs) crane;
version =
(builtins.fromTOML (builtins.readFile ../../crates/schemars-nixgen/Cargo.toml)).package.version;
in
{
mkNixgenPackages =
{ pkgs }:
let
toolchain = pkgs.rust-bin.fromRustupToolchainFile ../../rust-toolchain.toml;
craneLib = (crane.mkLib pkgs).overrideToolchain toolchain;
inherit
(import ../workspace-src.nix {
inherit pkgs craneLib;
repoRoot = ../..;
platform = "nixgen";
})
src
;
lockFile = lib'.repoFile "Cargo.lock";
tomlFile = lib'.repoFile "Cargo.toml";
commonArgs = {
pname = "schemars-nixgen";
inherit version src;
cargoExtraArgs = "--locked -p schemars-nixgen";
# the lock and the root manifest as files of their own: a path inside the filtered source
# would put all of it into the context of every derivation, and an edit of any file
# would then change the dependencies
cargoLock = lockFile;
cargoToml = tomlFile;
cargoVendorDir = craneLib.vendorCargoDeps {
cargoLock = lockFile;
inherit (lib') cargoLockParsed;
};
strictDeps = true;
};
# the dummy source is of the manifests alone (nix/lib.nix): the dependencies are the same
# derivations for every source file and every stub, and nothing is built at evaluation
cargoArtifacts = craneLib.buildDepsOnly (
builtins.removeAttrs commonArgs [ "src" ]
// {
dummySrc = craneLib.mkDummySrc {
src = lib'.manifestSource pkgs.lib;
cargoLock = lockFile;
};
}
);
individualCrateArgs = commonArgs // {
inherit cargoArtifacts;
doCheck = false;
doDoc = false;
};
schemars-nixgen = craneLib.buildPackage individualCrateArgs;
in
{
inherit
craneLib
src
individualCrateArgs
schemars-nixgen
;
};
}