Pagination on a custom post type loop

I found the final answer here: https://wordpress.stackexchange.com/a/217534/77722

Page 2 of front page was taking pagination from main query, not from my custom query.

I’ve taked these actions:

1. To change name of front-page.php to index.php in order to get the main query every time page is loaded (even when paginated)

2. To change main query with pre_get_posts in order to show posts of my CPT:

add_action( 'pre_get_posts', function ( $q ) {
    if (    $q->is_home() && $q->is_main_query() ) {
        $q->set( 'posts_per_page', 1 );
        $q->set( 'post_type', 'trabajo');
    }
});

3. Do a normal loop in the index.php:

if ( have_posts() ) {
    while ( have_posts() ) {
        the_post();
        the_title();
    }
}
wp_reset_postdata();
the_posts_navigation();

Works perfectly!