Cycles nodes: is it possible to get distance to nearest edge?
It's not the exact distance as you would say it, but it can be approximated using Bevel node in combination with Normal output of Texture Coordinate node.

The Bevel shader node can be used for rendering rounded corners. Like bump mapping, this does not modify the actual geometry, only the shading is affected. Slight rounding on edges helps to capture specular highlights that you would also see in the real world.

Bevel essentially gives blurred version of normal vectors depending on geometry, so you just have to measure the difference between them.
Shader node example


Samples controls smoothness
Radius means how farther from the edges will the samples taken
Alternatively use Color Ramp or Map Range node to control the falloff

Example results



As I said it is not precise and can be lead to unexpected results such as:

Edges marked smooth won't affect this
Edge between two faces with little normal change will have a little effect on this
You can't get exact value of a distance as it's done by random sampling, thus you can't do proper math with it(everything is either 0 or some fixed values)
Faces with multiple edges converging will report higher values, due to the nature of the method mentioned above
Render time will increase by 20% on average, as explained in the official doc.