There are a bunch of parts that you'll need to evaluate when you are in there.
You'll certainly want to replace the rings with the updated Mahle version with slots. Often the bottom end is in good condition but you'll want to replace the relatively inexpensive rod and wrist pin bearings.
The generic M54 rebuild kits are quite serviceable, including the head gasket itself.
M54 gasket kit contents
Head Gasket Kit
These are the typical contents of an aftermarket head gasket (“upper end”) kit
They are listed in roughly intake-to-exhaust order
11127501304 0.70mm Head gasket, MLS = multi-layer steel (1.0mm gasket is oversize)
11129070990 Valve cover gasket set, perimeter and two spark plug well gaskets (3 holes each)
11127526447 Oil fill gasket (large round ring)
13547504728 Profile gasket throttle body to intake manifold, 75.5mm for B25 engine
11349064457 24 valve stem seals (‘Viton’ is the preferred material)
11361433817 Vanos unit profile gasket (7 stud holes)
11537509357 Thermostat gasket (2 chamber)
11611437453 Idle Control Valve grommet (spigot shape)
11611436631 2 Intake manifold gaskets (3 ‘D’ holes each)
Small o-rings: 12 fuel injector seals, 2 per injector, different thickness, plus a sensor
13641437486 Injector O-ring lower 9.2x2.8 (injector-to-manifold), 6x
13641437487 Injector O-ring upper 7.5x3.52 (injector-to-fuel rail), 6x
13621743299 Air temperature sensor o-ring, 8x3 (easily confused with injector o-ring)
5-7 large o-rings (2 cam position green, two Vanos solenoid, water pipe)
2x 12141748398 Cam position sensors, 17x3
2x 11361703713 VANOS solenoid 21x2.5
2x 11531435808 water pipe o-rings 20x3 (sometimes only one in kit)
5 metal ring seals (chain adjuster, temperature sensor, 2x vanos oil line, plugs?)
32411093596 2x VANOS oil line 14x20 CuSn (often aluminum in kits)
07119963073 Plug at rear of head 13.5x10 Al
07119963130 Head coolant drain plug A12x15.5 Al
07119963418 Chain adjuster, 26x31 Al
11361433513 2 Vanos bolt plug w/ o-rings installed
11621732969 2x exhaust manifold gaskets with heat shield (3 holes each)
11727514860 Secondary air valve gasket (medium round, 2 small holes)
18107502346 2x Two stud downpipe gaskets (e39 exhaust)
2 Three stud downpipe gaskets (e46 exhaust)
Parts not included in a typical kit
O-ring for oil check valve in head 17x1.78 (1/16”, replaced with A015, Viton or HNBR)
VANOS seal set: sliding seals, energizer o-rings, and profile gaskets
11617502761 Air distribution piece O-rings 7mmx3mm (6x)
11121437395 Valve cover rubber washers 15x
Lower Gasket Kit
11111432478 BMW part number for full lower set
11131437237 - Gasket Steel, oil pan gasket
11141432240 - Gasket Steel, rear seal carrier
11141433639 - Lower Chain Case Metal Gasket, chain side
11141707260 - Lower Chain Case Metal Gasket, water pump side
11421719855 - Gasket, oil filter housing
11511711484 - O-ring 68X5 water pump
11142249532 - Shaft seal 48X65X10, front crank
11142249533 - Shaft seal 90X110X12, rear crank
11411432727 - O-ring 21,9X2,6 oil suction pipe o-ring for M52tu