Files
quixos-protocol/source-qualification.nix
T

85 lines
2.7 KiB
Nix
Raw Normal View History

{
pkgs,
library,
nixpkgsNarHash,
}:
let
comparisonIdentity = import ../tools/local-first/derivation-identity.nix;
# Inspect the actual .drv as data, without its derivation-deep output context.
productionDerivation = builtins.unsafeDiscardOutputDependency library.drvPath;
source = pkgs.lib.fileset.toSource {
root = ./.;
fileset = pkgs.lib.fileset.unions [
./src
./test
./grammar
./proto
./nix
./package.json
./yarn.lock
./.yarnrc.yml
./.yarn/plugins
./tsconfig.json
./tsconfig.build.json
./tsconfig.test.json
./default.nix
./yarn-project.nix
./flake.nix
./README.md
];
};
inputs = pkgs.writeText "protocol-source-inputs.json" (
builtins.toJSON {
inherit source nixpkgsNarHash productionDerivation;
narHashContext = builtins.getContext nixpkgsNarHash;
evaluatorVersion = builtins.nixVersion;
pinnedNixVersion = pkgs.nix.version;
nixpkgs = pkgs.path;
system = pkgs.stdenv.hostPlatform.system;
expected = comparisonIdentity library;
expectedSource = builtins.unsafeDiscardStringContext (toString library.src);
yarn = comparisonIdentity library.yarn-freestanding;
}
);
closure = pkgs.closureInfo {
rootPaths = [
pkgs.path
productionDerivation
];
};
in
pkgs.runCommand "quixos-protocol-source-check"
{
nativeBuildInputs = [
pkgs.nodejs_24
pkgs.nix
];
passthru.ciDiagnosticArtifacts."protocol-source.json" = {
file = "protocol-source.json";
maxBytes = 8192;
};
}
''
# The ordinary compiler still owns all tests and emitted fixtures. Finish
# that same checked build before the new identity-only evaluations.
test -e ${library}
export HOME="$TMPDIR/home"
export NIX_STATE_DIR="$TMPDIR/nix-state"
export NIX_LOG_DIR="$TMPDIR/nix-log"
export NIX_CONF_DIR="$TMPDIR/nix-conf"
export NIX_USER_CONF_FILES=/dev/null
export NIX_CONFIG='experimental-features = nix-command flakes
substituters =
builders =
max-jobs = 0
allow-import-from-derivation = false
accept-flake-config = false'
export QUIXOS_PROTOCOL_EVALUATION_STORE="$TMPDIR/evaluation-store"
mkdir -p "$HOME" "$NIX_STATE_DIR" "$NIX_LOG_DIR" "$NIX_CONF_DIR" "$QUIXOS_PROTOCOL_EVALUATION_STORE/nix/store"
while IFS= read -r dependency; do
cp -a --no-preserve=ownership "$dependency" "$QUIXOS_PROTOCOL_EVALUATION_STORE$dependency"
done < ${closure}/store-paths
nix-store --store "local?root=$QUIXOS_PROTOCOL_EVALUATION_STORE" --load-db < ${closure}/registration
timeout --kill-after=5s 180s node ${./source-qualification.mjs} ${inputs} "$out"
''