Adding (small) load to existing rafters with 2x4
Probably fine as far as weight goes. But I would not nail it, I would use construction screws (aka "deck screws") Pounding nails into the sides of those rafters may disturb your roof sheeting nails and or shingles, leading to leaks.