Just add the dtoverlay line to config.txt Raspberry Pi Config.txt [LibreELEC.wiki] adjust the temp parameter as needed. If you use a different GPIO than the default 12 you also have to add gpiopin=GPIONUMBER
The second link (to the gpio-fan-overlay.dts file) shows how the transistor should be hooked up and also contains a link to the RPi forum with more details Overlay for GPIO connected fan - Raspberry Pi Forums
Sorry if I reply to an old thread. I just wanted to know: the solution you provided still needs a transistor to work?