If an accidental detonation means just triggering some of the explosives, then yes, you'd get a dirty bomb. However, it's actually more likely that the bomb would actually detonate than the explosives being partially set off... they're designed specifically to be hard to detonate unless the actual detonator mechanism is used.
You'd be just as dead.
That said, Command Disable mechanisms on modern weapons don't result in a loud bang. However, there's no guarantee those mechanisms are all that are used in mechanisms which may deter physical penetration of vital areas of the weapon.
A 5 MT hydrogen bomb that "only" yields 750 kt of explosive power is a fizzle, but you don't want to be anywhere near when it happens.
This was a plot device in the popular Fallout games. Where a city had built up around a nuclear bomb which failed to detonate during a nuclear war.
Are these still basically a soccer ball of explosives encircling a core of subcritical nuclear material that "just" needs to be compressed?
I think all of my knowledge of nukes might be based on https://en.m.wikipedia.org/wiki/The_Manhattan_Project_(film) xD
You can replace the timing and electronics mechanism prior to that network, but probably any sort of tamper resistant mechanism for a weapon will remove part of that network of switches if removed from the device. The rest of the controls are just too easy to replace to be effective at keeping someone from a roll your own type solution.
You're effecting physical operations (movement, explosions) on such tight timescales that the software becomes part of the hardware. You can't just run the code on a different setup: the code is defined by the hardware it's running on, because it's orchestrating the physical properties of the hardware it's running on.
As an analogy, think about programming early video game systems or computers, where a single clock cycle was critical. Is the software just software? Or is it intertwined with the hardware it's running on? (See: emulators having to mimic actual hardware performance)
Either you brick a nuke in which case your boss bricks you, or the nuke bricks you and your local region.