Best practice for creating derivatives paths?

I’m struggling to understand the best practice for creating derivatives paths based on my input data.

For example, imagine I want to run freesurfer on a T1 at sub-01/ses-01/anat/sub-01_ses-01_T1w.nii.gz.
Ideally, I’d like to place the output at derivatives/sub-01/ses-01/anat/sub-01_ses-01_T1w.freesurfer (which I know may not be BIDS compliant, but its a start).

I’d like to build the path using layout.build_path(entities) where entities is a modified version of t1.get_entitites(). The issue with this approach is the generated path is alongside the original T1 image, not within derivatives/. Similarly, I’ve tried to add a derivatives layout to the original BIDSLayout but that fails because it lacks a dataset_description.

Could someone suggest the best practice here for generating derivatives paths based on the entities of an input, using pybids functions?