I'm creating a custom module and would like to allow the site editor to create a block and select which roles have access to the block. I'm looking for ideas on how to add this input field (select from existing roles) into the block settings.

Would appreciate being pointed at some example code I can use. 



This seems to work for me.

$roles = user_roles();
$form['my_role'] = array(
  '#type' => 'select',
  '#title' => 'My Role',
  '#options' => $roles,
  '#default_value' => $settings['my_role'],