A similar question was answered here.
This is called a Grenzgänger (Cross border commuter), for which special rules apply.
The best thing to do is to make an appointment at the Ausländerbehörde and ask them how the Grenzgänger rukesrules would apply for you.
Since you are working in Luxembourg, the German resident permit would only be needed to reside in Germany.
Income and social taxes are based on where you work
- with special rules dealing with usage of one where earned in another
There are organizations that assist with advice in these matters.
Sources: