It happened in real life. In the 1920's a guy named David Williams was arrested after a shootout while trying to shut down his North Carolina moonshine still. A deputy was killed and Williams was scented to 30 years.
While in prison he was allowed to work in the blacksmith shop and built his 1st gun there. It was so successful that Winchester representatives visited him in prison. They used his idea as the basis for the 30 Carbine rifle used by the military.
He was paroled in 1929 and is responsible for several firearms patents.
https://northcarolinahistory.org/enc...ams-1900-1975/
Jimmy Stewart played him in a movie released in 1952. Good movie if you've not seen it.