Scottish, Welsh and Northern Irish nationalist parties have signed a Cardiff agreement asserting the right to self-determination and calling for constitutional change in the UK.