mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-23 22:23:15 +00:00
3cc2e86bab
Examples: support has to be added to https://github.com/nix-community/nixdoc 'nixdoc --category testers --description "nixpkgs testers" --file ./pkgs/build-support/testers/default.nix'
27 lines
720 B
Nix
27 lines
720 B
Nix
{ lib, runCommand, emptyFile, nix-diff }:
|
|
|
|
assertion: a: b:
|
|
let
|
|
drvA = builtins.unsafeDiscardOutputDependency a.drvPath or (throw "testEqualDerivation second argument must be a package");
|
|
drvB = builtins.unsafeDiscardOutputDependency b.drvPath or (throw "testEqualDerivation third argument must be a package");
|
|
name =
|
|
if a?name
|
|
then "testEqualDerivation-${a.name}"
|
|
else "testEqualDerivation";
|
|
in
|
|
if drvA == drvB then
|
|
emptyFile
|
|
else
|
|
runCommand name
|
|
{
|
|
inherit assertion drvA drvB;
|
|
nativeBuildInputs = [ nix-diff ];
|
|
} ''
|
|
echo "$assertion"
|
|
echo "However, the derivations differ:"
|
|
echo
|
|
echo nix-diff $drvA $drvB
|
|
nix-diff $drvA $drvB
|
|
exit 1
|
|
''
|