I’m a sucker for a man who reads Yeats. So I’m bound to like a man who bases his novel on an obscure Yeats play.

“When I was at Yale in graduate school, a friend of mine brought me to see a play that the undergraduates were doing, and it was ‘The Only Jealousy of Emer,’” David Duchovny recalls one rainy day over lattes at Tavern on the Green in New York City.

“It’s a verse play, so it’s kind of unwatchable. But I got the gist of it, which was a very cool wager about love, and it stayed with me forever.”

Naturally, since this is Fox Mulder of The X-Files, there’s a supernatural element and a parallel universe. And since this is also Hank Moody of Californication, there’s some drinking and womanising, too.

In the Ulster Cycle of Irish mythology, Emer and the warrior hero Cuchulainn fall in love and marry after trading cryptic riddles.

The Yeats play conjures a moment when Cuchulainn inadvertently kills his own son in battle and then, distraught, begins fighting “the deathless sea” and almost drowns. A demonic Irish fairy, called a Sidhe, appears and offers Emer a cruel bargain: If she gives up her fondest hope that the warrior will tire of his mistress — also at his sickbed — and grow old with her, the fairy will let Cu Chulainn live.

“He’ll never sit beside you at the hearth,” the Sidhe tells Emer, “Or make old bones, but die of wounds and toil, on some far shore or mountain, a strange woman beside his mattress.”

After agonising over the choice, Emer finally says, “If he may live I am content.”

In Miss Subways, published by Farrar, Straus & Giroux, Duchovny modernises this myth into the tale of Emer Gunnels, a 41-year-old New York schoolteacher who likes to take the subway and eat ice cream and make love with her boyfriend, Cuchulain, a writer known as Con.

But a troublemaking pint-size doorman, Sid, who is a Sidhe, shows up at her apartment with a cruel bargain: Emer can save her boyfriend from being hit by a car outside Nobu, where he is out flirting with another woman. But Emer has to give him up, along with her dream of walking arm in arm with Con on the beach when they are old.

Occasional vegetarian

He dropped out of Yale before writing his Ph.D. dissertation, which was to be “Magic and Technology in Contemporary American Fiction and Poetry.” (His senior thesis at Princeton was titled “The Schizophrenic Critique of Pure Reason in Beckett’s Early Novels.”)

Like his 2004 movie, “House of D,” which he wrote and directed, his new novel is a meditation on his hometown — “So much of New York involved looking away” — and his heroine, Emer, has many of the same traits as Duchovny.

Like her creator, Emer has green eyes with different-sized pupils, which reflect “some charismatic, universal, lighthearted melancholy, like she saw things at a distance, a gently ironic remove.”

She’s a reader, “it defined her.” She does not “like to kill anything and has been an on-and-off, semi-strict, nondogmatic, occasional vegetarian since college.” (But she makes an exception on the killing ban for mosquitoes and really good sushi.)

She thinks Twitter is the end of the world. And she is a schoolteacher, like Duchovny’s mother, Meg, who was a cherished teacher at Grace Church School in Greenwich Village and his sister, Laurie, who is a teacher at St Ann’s in Brooklyn.

The book is dedicated to his 88-year-old mother, and he has Con tell Emer a story that actually happened to Duchovny and his mom when he was a boy eager to see the dinosaurs at the Museum of Natural History.

They missed their subway stop and ended up, flummoxed, in Queens. As Duchovny writes in his dedication: “Our curiosity and incompetence taught us it’s not the destination, it’s the ride ... stay on the train, the scenery will change.’’

Female voice

The author, who has written two previous novels, has no trouble slipping into the female voice. He was a jock who dreamed of playing basketball at Princeton, which he did for a year on the junior varsity team before “the heartbreak” of no longer being on the team.

But he was professionally gender-fluid before that term became popular. He suggested a plotline to his friend Garry Shandling for The Larry Sanders Show in which he played himself hitting on Shandling, doing the Sharon Stone opening-the-kimono reveal.

On Twin Peaks, he played a detective in drag named Dennis who liked it so much he transitioned into Denise. “High heels and tights and underwire bras are painful,” Duchovny says with a grimace. “I had marks, I had bruises. It’s not fun.”

His father, a publicist and writer, left and moved to Boston when Duchovny was young. The way he, his brother and sister were raised by his mother, he says, made him think that “there was no difference between men and women — not intellectual, emotional, spiritual”.

“I’m aware that I don’t understand what it’s like to be a woman, be attacked as a woman, to feel endangered as a woman, to be abused as a woman. But I feel like I could hear Emer’s voice in my head. And I know ‘appropriation’ is a dirty word these days, but that’s all an artist can do. I mean, there is no art without appropriation. You take what you find and you make a collage and you imagine the rest.

“You want me to imagine what it’s like to be a woman, to put myself in a black man’s shoes or a black woman’s shoes,” he says. “That’s actually what we all should be trying to do, whether or not we come up with a nice work of fiction from it or it’s horrible and you got it all wrong.

“I really feel like the wrong way to go about it is to try to imagine that there are some movies that should be told by women as opposed to by men. And so a woman can direct any movie and a man can direct any movie and you hope you can get it to a meritocracy at some point. If you say, ‘No, you can’t do that,’ then you’re shutting down exactly the impulse that you want to come out of this bomb that went off in our culture.”

After the Harvey Weinstein revelations, he said, he had to “re-educate” himself. He said his belief in equality between men and women and blacks and whites skewed his perception of the problem.

“So my education has been to acknowledge that even if I didn’t perpetuate it, it has to be dealt with — if I’m not being part of the solution I’m being part of the problem,” he says, adding that witnessing all the hatred and division that has cascaded since the advent of Trump has “reopened” his eyes to misogyny and racism.

Gillian Anderson has complained that after struggling for years to get equal pay for playing Scully — initially, as a newcomer, the actress was even told to stand several feet behind Duchovny in scenes — she was at first offered half of Duchovny’s salary for The X-Files revival.

When I mention that only 4 percent of women directed the top 100 grossing films, he shakes his head. “That’s mind-blowing.”

Not bad for an actor

Duchovny, whose Twitter biography at one point was simply “Dilettante,” has also gotten a band together and he has made two albums, Hll or High Water” and Every Third Thought.

Rolling Stone described his first album as “lyrically tart” and “vaguely Wilco-ish.” Critics were less kind to the second album.

“I think people like you to stay in your lane, and it’s easy to take potshots at me for dabbling, I imagine, but that’s OK,” he says, adding that he is waiting for the “Not bad for an actor” reviews of his book.

After his divorce from the actress Téa Leoni in 2014, he learned to play guitar, asking the writers of Californication to weave in Hank’s playing “so I could get free guitar lessons from the show.”

I ask if a song on his first album that mentions a 12-step programme — “Three thousand steps, forget about 12” — alludes to his 2008 stint in a sex-addiction clinic, an attempt to save his 17-year marriage to Leoni, with whom he has an 19-year-old daughter and a 15-year-old son.

“Yeah,” he says. “I think there’s wisdom to be had in looking at any kind of behaviours that we do to manage our unease and make ourselves feel better or to alter our consciousness.”

He has, however, given up therapy, because shrinks tend to shrink, as he likes to say, a line he says he borrowed from his old Yale professor Harold Bloom.

Poignantly, his ring finger still has a wedding tattoo, of the letters AYSF, which stand for At Your Side Forever. “But people think the AYSF is American Youth Soccer Foundation, and I tell them, ‘Yes, that’s it,’” Duchovny says. “I’m a big fan of the game.”

Two men at the restaurant stop by to say they loved Californication.