To the OP if you buy the truck I suggest you read up on the engine's history, weaknesses and proven remedies. Also I suggest you find a good independent diesel shop that is well versed in this engine.
I don't think it is as bad as some paint it here but it definitely ain't a set it and forget it type of engine.
Yes it had emissions issues and engineering shortcomes vs other engines. Yes stock engines that were maintained had issues but more than a few times the issues are from dirty fuel, non OEM parts, poor maintenance, racing/beating, box tunes, shops not knowing proper procedures, etc.
Regards to engines with multiple head gasket replacements many reputable diesel shops say they get most of their business from owners who had their head gaskets done (improperly) at other shops. Its not something any shade tree tech can do right to last.
The engine definitely has a mixed bag reputation. Some love them some despise them. I have had a few from stock to modded, from DD to dedicated tow rig. I would get another one sure but I wouldn't recommend it to someone who isn't prepared for the possibilities.