It can be done. Are you comfortable with wiring? Will the install be subject to code/inspection?
I suggest securing the wire such that it can't slide easily, and providing at least a little slack where it attaches to the fixture. This prevents strain on your connections. There are also clamps that will do the same, but need to be matched to the electrical box that you use. Not all box/clamp combinations will work.
Securing the wire as above, plus making sure the very end of the wire near the light fixture has
a little freedom of movement can help avoid a future short. For example, don't cut the ceiling for your box with a snug fit and recess it like a typical install, then put your wire into the hole and shove in the box. Or don't put the wire in the box from below, then screw on a tight cover. Both of those methods risk damage to the insulation that could cause a short, or shock you in the future during servicing. Instead consider installing the box as normal and passing the wire through the ceiling with a seperate hole beside it, or hanging the box from the ceiling and installing the wire through a side knock-out, or plugging the cord in inside the attic so the wire
never crosses the ceiling.