How do you work with nested modules?

So what’s the idiomatically correct way to do nested modules? I know when applications you tend to do it the first way and follow the directory hierarchy, but when to choose one over the other because I do see it done both ways? The only time I do it the second way is if all I need are a bunch of structs.

defmodule Foo do
   ...
end

then

defmodule Foo.Bar do
    ...
end

VS

defmodule Foo do
 
    defmodule Foo.Bar do
        ...
    end
    ....
end