Skip to content

Commit

Permalink
lib/all-attrs.nix: add a flag to dig into derivations themselves
Browse files Browse the repository at this point in the history
  • Loading branch information
trofi committed Dec 28, 2023
1 parent 9cabacc commit 50ed200
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/all-attrs.nix
Expand Up @@ -35,6 +35,11 @@
, maxDepth

, ignoreCross ? true

# Whether to validate every attribute within derivations themselves.
# Most intereting fields are `passthru.tests`, but sometimes there are
# very unusual bugs lurking. Risky but very fun!
, ignoreDrvAttrs ? true
}:

let
Expand Down Expand Up @@ -76,11 +81,9 @@ let
in debug "inspecting ${a}" (
if !e.success then info "${a} fails to evaluate" []
else if lib.isDerivation v
# TODO: add an option to traverse into derivations as well.
# Mainly to test validity of `passthru.tests`, `metadata` and
# similar.
then [a] # TODO: "++ maybe_go_deeper"
then [a] ++ lib.optionals (!ignoreDrvAttrs) maybe_go_deeper
# Skip "foo = self;" attributes like `pythonPackages.pythonPackages`
# TODO: might skip too much.
else if lib.isAttrs v && depth > 0 && lib.hasAttr (lib.last ap) v then info "${a} is a repeated attribute, skipping" []
else if lib.isAttrs v then maybe_go_deeper
else if isPrimitive v then []
Expand Down

0 comments on commit 50ed200

Please sign in to comment.