“There are so many layers to the song,” Columbia Records chairman Ron Perry says of “Old Town Road.” Just scratching the surface of its beat alone uncovers the connection between a 19-year-old Dutch Internet producer and veteran industrial act Nine Inch Nails, who are now forever intertwined in pop culture — along with Billy Ray Cyrus.

The origin story of these strange bedfellows starts in a village outside Amsterdam, where student Kiowa Roukema, who goes by YoungKio professionally, found unlikely inspiration in a decade-old song he sampled from NIN’s mostly acoustic sixth album, “Ghosts I — IV.” He built a beat around it from the comfort of his home and it only took $180 — the cost of membership for digital music marketplace BeatStars — to engage with consumers from all over the world.

As YoungKio recalls: “I was randomly digging for samples on YouTube — underground releases and old records from the 1960s — when the platform recommended that video. I clicked and heard the first couple seconds. Then the banjo came in. It sounded really different, but in a good way. The melody was so beautiful. It did something to me and I knew I had to use it. It took me around 35 minutes to make the beat.”

The 20-year-old music-maker, who’s now based in L.A., says “some older producers” told him “that it was, in their eyes, unusable.” But, YoungKio adds, “in my view, it was perfect.”

Finding his way to the country-trap mash-up the world didn’t know it needed, Lil Nas X paid a mere $30 to download YoungKio’s beat from BeatStars, and instantly became obsessed. Nas recorded “Old Town Road” in under an hour at a local Atlanta studio that offered a weekly reduced rate — $20 Tuesdays — and released it on Dec. 3, 2018.

“I didn’t even know there was a sample until months after,” says Nas. “I was like: ‘S–t!’ ”

As the story goes, “Old Town Road” first went viral on TikTok, later cracked charts in R&B/hip-hop and country, sparked a bidding war won by Columbia, and proceeded to the No. 1 spot, where it sat for 19 weeks.

“Luckily, Trent Reznor [and Atticus Ross] approved of the sample because if he didn’t, I don’t know where I would be right now,” says Nas, who hired a lawyer recommended by his new label to hammer out a deal. “I don’t know if they have 50%, but they get a good [size] share of the royalties, which they 100% deserve. I mean, the song wouldn’t be here without them. I was, like, ‘I don’t care if he takes 99% of the royalties — just let the song stay out.’ Because I can build off it, you know?”