I can't give anyone a non-GPL licence to this work, which is what they were demanding.
IANAL, but are you sure this is the case? I believe that in my country (Norway) at least, you're still the sole proprietor of your IP.
I am the owner of any code I sumbit to the Linux kernel, *but* it is also considered a "derived work" of the rest of the kernel (which means, legally, I'm not the *sole* owner) and therefore the GPL applies.
Did they want to gain exclusive rights to code you'd already published under the GPL?
The contract was non-specific on what code they were talking about - it was a blanket "you will give us a perpetual nonexclusive licence to do what we want with any IP in your ownership which you produced before, after or during your employment with us" (or words to that effect - I can't recall the exact wording).
I don't know how legal it was - as I mentioned, the company in question was already ignoring their TUPE obligations. However, legal or not, I saw no merit in signing it, so I didn't.
Does the GPL preclude that you grant, for instance, a BSD or Apache license for code which you wrote yourself?
The GPL doesn't prevent dual-licensing code for which you are the sole owner (i.e. you wrote it, or the copyright was assinged to you; and it is not derived from anyone else's code). This even extends to commercial licences - i.e. I can write some code and release it under GPL, at the same time as selling a paid-for licence with non-GPL terms to a few people. However, when you contribute code to an existing project, it is usually considered to be a "derived work" since it almost always makes use of existing parts of that project's code - therefore the writer of contributed code would seldom be considered the sole owner, so whatever licence it is released under would need to be fully compatible with the licence used on the rest of the project. This generally precludes dual-licencing code that has been contributed to a GPLed project.
Much like other copyrighted stuff like music - if you make a song that is derived directly from someone else's song then you can't just blindly release it yourself - generally to release a derived song you need to get a licence to do so from the owner of the original song.