tvl-depot/tvix/cli/default.nix
Florian Klink 1fb5008237 feat(tvix/cli): introduce mkNixpkgsEvalCheck, add outPath check
This introduces a function that can be instantiated with an attribute
path to instantiate, as well as the expected path (normally interpolated
with the nix evaluator).

Check both pkgs.stdenv.drvPath and pkgs.stdenv.outPath to match.

Change-Id: Id667ed35fa159ff83fedb3017ef8d3271aa42695
Reviewed-on: https://cl.tvl.fyi/c/depot/+/8606
Reviewed-by: tazjin <tazjin@tvl.su>
Autosubmit: flokli <flokli@flokli.de>
Tested-by: BuildkiteCI
2023-05-24 09:17:41 +00:00

32 lines
1,003 B
Nix

{ depot, pkgs, lib, ... }:
let
mkNixpkgsEvalCheck = attrset: expectedPath: {
label = ":nix: evaluate nixpkgs.${attrset} in tvix";
needsOutput = true;
command = pkgs.writeShellScript "tvix-eval-${builtins.replaceStrings [".drv"] ["-drv"] attrset}" ''
TVIX_OUTPUT=$(result/bin/tvix -E '(import ${pkgs.path} {}).${attrset}')
EXPECTED='${/* the verbatim expected Tvix output: */ "=> \"${expectedPath}\" :: string"}'
echo "Tvix output: ''${TVIX_OUTPUT}"
if [ "$TVIX_OUTPUT" != "$EXPECTED" ]; then
echo "Correct would have been ''${EXPECTED}"
exit 1
fi
echo "Output was correct."
'';
};
in
(depot.tvix.crates.workspaceMembers.tvix-cli.build.override {
runTests = true;
}).overrideAttrs (_: {
meta = {
ci.extraSteps = {
eval-nixpkgs-stdenv-drvpath = (mkNixpkgsEvalCheck "stdenv.drvPath" pkgs.stdenv.drvPath);
eval-nixpkgs-stdenv-outpath = (mkNixpkgsEvalCheck "stdenv.outPath" pkgs.stdenv.outPath);
};
};
})