pytrainer: unpin python 3.10
[NixPkgs.git] / pkgs / build-support / testers / test-equal-derivation.nix
blob610d5f58557608c349d0370cd74312d9d2adec2d
1 { lib, runCommand, emptyFile, nix-diff }:
3 assertion: a: b:
4 let
5   drvA = builtins.unsafeDiscardOutputDependency a.drvPath or (throw "testEqualDerivation second argument must be a package");
6   drvB = builtins.unsafeDiscardOutputDependency b.drvPath or (throw "testEqualDerivation third argument must be a package");
7   name =
8     if a?name
9     then "testEqualDerivation-${a.name}"
10     else "testEqualDerivation";
12 if drvA == drvB then
13   emptyFile
14 else
15   runCommand name
16     {
17       inherit assertion drvA drvB;
18       nativeBuildInputs = [ nix-diff ];
19     } ''
20       echo "$assertion"
21       echo "However, the derivations differ:"
22       echo
23       echo nix-diff $drvA $drvB
24       nix-diff $drvA $drvB
25       exit 1
26     ''