Democrats struck a rare deal with Trump to separate funding for the Homeland Security Department from a broad government spending bill.