modules/dependencies: refactor all-examples test

Embed the original `path` as an attr in the literal expression, so that
we don't need to convert back from human readable paths in the test.
This commit is contained in:
Matt Sturgeon 2025-04-12 05:30:59 +01:00
parent 1095b7f891
commit 16879e3034
No known key found for this signature in database
GPG key ID: 4F91844CED1A8299
2 changed files with 23 additions and 7 deletions

View file

@ -30,12 +30,14 @@
}:
{
dependencies = lib.pipe options.dependencies [
(lib.filterAttrs (_: depOption: depOption.package ? example))
# We use a literalExpression example, with an additional `path` attr.
# This means we don't have to convert human readable paths back to list-paths for this test.
(lib.filterAttrs (_: depOption: depOption.package ? example.path))
(lib.mapAttrs (
_: depOption:
let
packageName = depOption.package.example.text;
packagePath = lib.splitString "." packageName;
packagePath = depOption.package.example.path;
packageName = lib.showAttrPath packagePath;
package = lib.attrByPath packagePath (throw "${packageName} not found in pkgs") pkgs;
in
{