Skip to content

feat: support nested nova_apps#380

Open
Taure wants to merge 2 commits intonovaframework:masterfrom
Taure:feat/nested-nova-apps
Open

feat: support nested nova_apps#380
Taure wants to merge 2 commits intonovaframework:masterfrom
Taure:feat/nested-nova-apps

Conversation

@Taure
Copy link
Copy Markdown
Collaborator

@Taure Taure commented Mar 25, 2026

Summary

Nova apps can now declare their own nova_apps dependencies. When compiling routes, Nova recursively resolves all nested nova_apps depth-first so child app routes are registered before the parent.

Before

Users must manually list all transitive nova_apps:

{my_app, [{nova_apps, [arizona_nova, shigoto_board]}]}

After

Library apps declare their own dependencies:

%% shigoto_board app env
{shigoto_board, [{nova_apps, [arizona_nova]}]}

Users only list what they need:

{my_app, [{nova_apps, [shigoto_board]}]}

Nova resolves: shigoto_board → arizona_nova automatically.

Implementation

  • Added resolve_nova_apps/2 to nova_sup.erl
  • Recursive depth-first resolution
  • Cycle detection (skips already-resolved apps)
  • No changes to route compilation or existing behaviour

Test plan

  • rebar3 eunit — 347 tests pass
  • rebar3 xref — clean
  • rebar3 compile — clean

Nova apps can now declare their own nova_apps dependencies.
When compiling routes, Nova recursively resolves all nested
nova_apps depth-first so child app routes are registered
before the parent.

This allows library nova_apps like shigoto_board to declare
their dependencies (e.g. arizona_nova) so users only need:

    {my_app, [{nova_apps, [shigoto_board]}]}

Instead of manually listing all transitive nova_apps.

Cycle detection prevents infinite loops if apps reference
each other.
src/nova_sup.erl Outdated
App ->
ExtraApps = application:get_env(App, nova_apps, []),
nova_router:compile([nova|[App|ExtraApps]])
AllApps = resolve_nova_apps(ExtraApps, []),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should probably call resolve_nova_apps([nova|[App|AllApps]]) instead so that you don't hit multiple occurrences of nova or App.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I will look at it.

Route nova and the bootstrap app through resolve_nova_apps so the
cycle detection prevents duplicates if nested apps also reference them.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants