How to replace allowed_values for a select field by external definition?
Instead of allowed_values you can add a callback to set the allowed values:

  -&gt;setSettings(['allowed_values_function' =&gt; 'callback_allowed_values_function'])


The callback:

function callback_allowed_values_function(FieldStorageDefinitionInterface $definition, FieldableEntityInterface $entity = NULL, &amp;$cacheable = TRUE) {
  if (isset($entity) &amp;&amp; ($entity-&gt;bundle() == 'not_a_programmer')) {
    $values = [
      1 =&gt; 'One',
      2 =&gt; 'Two',
    ];
  }
  else {
    $values = [
      'Group 1' =&gt; [
        0 =&gt; 'Zero',
        1 =&gt; 'One',
      ],
      'Group 2' =&gt; [
        2 =&gt; 'Two',
      ],
    ];
  }

  return $values;
}


You can get the allowed values from a text file or put the callback in an include file.

For more information see options.api.php



A different approach might be to store the allowed values in config, for which there is a bundle specific base field override, see How to easily alter an entity&#39;s base field definition per bundle. Then you can manage the allowed values list in a yaml file of an exported config.