diff --git a/ci/install_compilers.sh b/ci/install_compilers.sh
index 46e19e096f15c677de8d1eb1fd33a8165f82bd86..3c5547b74d6b9829b5754e8be818dab448d0410d 100755
--- a/ci/install_compilers.sh
+++ b/ci/install_compilers.sh
@@ -131,10 +131,21 @@ jq -Mrc '
  | .system_arch as $arch
  | .compilers
  | to_entries
+ | map(select(.value.constraint == null))
  | map(" - compiler_\(.key): [\(.value.compiler)@\(.value.version) target=\(env.target)]")
  | .[]
 '  ${STACK_CONFIG} >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
 
+jq -Mrc '
+.stack
+ | .system_arch as $arch
+ | .compilers
+ | to_entries
+ | map(select(.value.constraint != null))
+ | map(" - compiler_\(.key): []\n - when: \(.value.constraint)\n   compiler_\(.key): [\(.value.compiler)@\(.value.version) target=\(env.target)]")
+ | .[]
+'  ${STACK_CONFIG} >> ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
+
 cat ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml
 #yq -y -s  ".[0].spack.definitions = .[1].definitions + .[0].spack.definitions | .[0]" ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml ${SPACK_SYSTEM_CONFIG_PATH}/compiler_definitions.yaml > ${SPACK_SYSTEM_CONFIG_PATH}/spack.yaml.new