nixpkgs/ci/parse.nix
Wolfgang Walther 5f306bed7b ci/parse: fix potential race condition
The parse check runs multiple `nix-instantiate` processes in parallel -
and they can error out with "SQLite database '...' is busy" while
setting up the state directories. This was observed once locally.

Initialising the store should fix this.

(cherry picked from commit a2def7f914)
2025-10-18 18:22:32 +00:00

35 lines
828 B
Nix

{
lib,
nix,
runCommand,
}:
let
nixpkgs =
with lib.fileset;
toSource {
root = ../.;
fileset = (fileFilter (file: file.hasExt "nix") ../.);
};
in
runCommand "nix-parse-${nix.name}"
{
nativeBuildInputs = [
nix
];
}
''
export NIX_STORE_DIR=$TMPDIR/store
export NIX_STATE_DIR=$TMPDIR/state
nix-store --init
cd "${nixpkgs}"
# This will only show the first parse error, not all of them. That's fine, because
# the other CI jobs will report in more detail. This job is about checking parsing
# across different implementations / versions, not about providing the best DX.
# Returning all parse errors requires significantly more resources.
find . -type f -iname '*.nix' | xargs -P $(nproc) nix-instantiate --parse >/dev/null
touch $out
''