Merging mounts from two or more plugins

I’m stuck with this:

  • I have mounts from two plugins, and mount from tutor mounts add
  • Tried some hooks to merge all what I want in one MOUNTS directive in config.yml
  • I found solution with collecting all mounts records in one environ variable (not sure it’s good)
  • Can’t find how to remove mounts when plugin disables.
mounts: list[str] = ["mount1", "mount2", ... etc]

def add_myplugin1_mounts_to_environ(plugin: str):
    if plugin == "myplugin1" and mounts:
        env_var: str = os.environ.get("MOUNTS_ADD", None)
        if env_var is None:
            env_mounts: list[str] = []
            env_mounts: list[str] = serialize.parse(env_var)
        for mount in mounts:
            if mount not in env_mounts:
        os.environ.update({"MOUNTS_ADD": str(env_mounts)})

def write_mounts_to_config():
    config: Config = tutor_config.load_minimal(ROOT_PATH)
    config_mounts: list[str] = config.get("MOUNTS", [])
    mounts_add: list[str] = []
    env_mounts_add: str = os.environ.get("MOUNTS_ADD", "")
    if env_mounts_add:
        mounts_add = serialize.parse(env_mounts_add)
    for mount in mounts_add:
        if mount not in config_mounts:
    if config_mounts != config.get("MOUNTS", None):
        config.update({"MOUNTS": config_mounts})
        tutor_config.save_config_file(ROOT_PATH, config)

Tried PLUGIN_UNLOADED hook and when plugin disables loads config, when I load and change config in my callback all my changes overrides with save_config_file from outer scope.