`eval` in custom phase

I’m working on a program with a separate test suite. To run it I defined a custom checkPhase following instructions at Sandia National Laboratories: Xyce Parallel Electronic Simulator (Xyce): Running the Xyce Regression Suite (absolute paths required)

  checkPhase = ''
    XYCE_BINARY="$(pwd)/src/Xyce"
    EXECSTRING="${if withMPI then "mpirun -np 2 " else ""}$XYCE_BINARY"
    TEST_ROOT="$(pwd)/../Xyce_Regression-Release-${version}"
    eval $($TEST_ROOT/TestScripts/suggestXyceTagList.sh "$XYCE_BINARY")
    echo "Test taglist: ''${TAGLIST}"
    $TEST_ROOT/TestScripts/run_xyce_regression \
      --output="$(pwd)/Xyce_Test" \
      --xyce_test="''${TEST_ROOT}" \
      --taglist="''${TAGLIST}" \
      --resultfile="$(pwd)/test_results" \
      "''${EXECSTRING}"
  '';

The peculiar thing that I’m observing is related to the line
eval $($TEST_ROOT/TestScripts/suggestXyceTagList.sh "$XYCE_BINARY").
The inner script is supposed to returns a list of variable definitions by printing (using echo) a string of the form TAGLIST="+nightly..." which is then evaluated.

When I build the derivation with nix-build the checkPhase is run, but the above line doesn’t set any variable and the phase terminates without running any test. To debug this I installed the breakpointHook and entered the build sandbox with cntr. The strange thing is that, if in the sandbox I run eval "$checkPhase" manually, everything behaves as expected: The variable TAGLIST is set and all tests are run.

I would appreciate any hint at why this may be happeninng.