It turns out that the Scottish Parliament may have the legal power to block Brexit:
Not many people are familiar with section 2 of the Scotland Act of 2016, but it could give First Minister Nicola Sturgeon and her government in Edinburgh the legal power to block the UK from triggering Article 50. Conservative MP Anna Soubry - in a wonderfully honest interview in The Guardian yesterday - mentioned it in passing:
The government is appealing against the high court ruling, but at the supreme court hearing, the Scottish government will argue that the consent of Holyrood is also required to trigger article 50. Soubry thinks it has a strong case. “Yes. I’m reliably informed that the Scotland Act 2016 section 2 says that you cannot interfere with devolved Scottish matters, they must be determined by the Scottish parliament.”
The application of EU law in Scotland is a devolved matter. Which means the consent of the Scottish Parliament is required if Westminster wants to remove it (just as the consent of the NZ Parliament used to be required if the UK Parliament legislated something which affected us).
Of course, the deal here is obvious: Holyrood will consent to Brexit if Westminster consents to Scoxit. And the two countries can then happily go their separate ways. Sadly, I expect the "English nationalists" (actually English supremacists) who backed Brexit won't be happy with that though...