tests.nixpkgs-check-by-name: Sort the eval validation results
Not that important, but nice. Also adds a nice test case show-casing the two current ratchet checks at once.
This commit is contained in:
parent
57afdc545b
commit
cbff02834f
@ -79,26 +79,22 @@ let
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
byNameAttrs = map (name: [
|
byNameAttrs = builtins.listToAttrs (map (name: {
|
||||||
name
|
inherit name;
|
||||||
{
|
value.ByName =
|
||||||
ByName =
|
|
||||||
if ! pkgs ? ${name} then
|
if ! pkgs ? ${name} then
|
||||||
{ Missing = null; }
|
{ Missing = null; }
|
||||||
else
|
else
|
||||||
{ Existing = attrInfo name pkgs.${name}; };
|
{ Existing = attrInfo name pkgs.${name}; };
|
||||||
}
|
}) attrs);
|
||||||
]) attrs;
|
|
||||||
|
|
||||||
# Information on all attributes that exist but are not in pkgs/by-name.
|
# Information on all attributes that exist but are not in pkgs/by-name.
|
||||||
# We need this to enforce pkgs/by-name for new packages
|
# We need this to enforce pkgs/by-name for new packages
|
||||||
nonByNameAttrs = map (name:
|
nonByNameAttrs = builtins.mapAttrs (name: value:
|
||||||
let
|
let
|
||||||
output = attrInfo name pkgs.${name};
|
output = attrInfo name value;
|
||||||
result = builtins.tryEval (builtins.deepSeq output null);
|
result = builtins.tryEval (builtins.deepSeq output null);
|
||||||
in
|
in
|
||||||
[
|
|
||||||
name
|
|
||||||
{
|
{
|
||||||
NonByName =
|
NonByName =
|
||||||
if result.success then
|
if result.success then
|
||||||
@ -106,7 +102,14 @@ let
|
|||||||
else
|
else
|
||||||
{ EvalFailure = null; };
|
{ EvalFailure = null; };
|
||||||
}
|
}
|
||||||
]
|
) (builtins.removeAttrs pkgs attrs);
|
||||||
) (builtins.attrNames (builtins.removeAttrs pkgs attrs));
|
|
||||||
|
# All attributes
|
||||||
|
attributes = byNameAttrs // nonByNameAttrs;
|
||||||
in
|
in
|
||||||
byNameAttrs ++ nonByNameAttrs
|
# We output them in the form [ [ <name> <value> ] ]` such that the Rust side
|
||||||
|
# doesn't need to sort them again to get deterministic behavior (good for testing)
|
||||||
|
map (name: [
|
||||||
|
name
|
||||||
|
attributes.${name}
|
||||||
|
]) (builtins.attrNames attributes)
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
self: super: {
|
||||||
|
a = self.callPackage ./pkgs/by-name/a/a/package.nix { };
|
||||||
|
b = self.callPackage ({ someDrv }: someDrv) { };
|
||||||
|
c = self.callPackage ./pkgs/by-name/c/c/package.nix { };
|
||||||
|
d = self.callPackage ({ someDrv }: someDrv) { };
|
||||||
|
}
|
@ -0,0 +1 @@
|
|||||||
|
import ../mock-nixpkgs.nix { root = ./.; }
|
@ -0,0 +1,4 @@
|
|||||||
|
pkgs.a: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage pkgs/by-name/a/a/package.nix { ... }` with a non-empty second argument.
|
||||||
|
pkgs.b: This is a new top-level package of the form `callPackage ... { }`. Please define it in pkgs/by-name/b/b/package.nix instead. See `pkgs/by-name/README.md` for more details. Since the second `callPackage` argument is `{ }`, no manual `callPackage` (e.g. in `pkgs/top-level/all-packages.nix`) is needed anymore.
|
||||||
|
pkgs.c: This attribute is manually defined (most likely in pkgs/top-level/all-packages.nix), which is only allowed if the definition is of the form `pkgs.callPackage pkgs/by-name/c/c/package.nix { ... }` with a non-empty second argument.
|
||||||
|
pkgs.d: This is a new top-level package of the form `callPackage ... { }`. Please define it in pkgs/by-name/d/d/package.nix instead. See `pkgs/by-name/README.md` for more details. Since the second `callPackage` argument is `{ }`, no manual `callPackage` (e.g. in `pkgs/top-level/all-packages.nix`) is needed anymore.
|
@ -0,0 +1 @@
|
|||||||
|
{ someDrv }: someDrv
|
@ -0,0 +1 @@
|
|||||||
|
{ someDrv }: someDrv
|
Loading…
Reference in New Issue
Block a user