nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 runCommand,
4 emptyFile,
5 nix-diff,
6}:
7
8assertion: a: b:
9let
10 drvA =
11 builtins.unsafeDiscardOutputDependency
12 a.drvPath or (throw "testEqualDerivation second argument must be a package");
13 drvB =
14 builtins.unsafeDiscardOutputDependency
15 b.drvPath or (throw "testEqualDerivation third argument must be a package");
16 name = if a ? name then "testEqualDerivation-${a.name}" else "testEqualDerivation";
17in
18if drvA == drvB then
19 emptyFile
20else
21 runCommand name
22 {
23 inherit assertion drvA drvB;
24 nativeBuildInputs = [ nix-diff ];
25 }
26 ''
27 echo "$assertion"
28 echo "However, the derivations differ:"
29 echo
30 echo nix-diff $drvA $drvB
31 nix-diff $drvA $drvB
32 exit 1
33 ''