Using system environment variables in 'variables:' section?

Is there a way to access system environment variables in the variables: section?

I created something like this:

my-job:
  variables:
    SOME_DIR: $HOME/some/dir

Then I wondered for the longest time why in the script section $SOME_DIR was /some/dir instead of /user/home/some/dir. I understand that $HOME is not a predefined (build) environment variable. Yet, can I somehow access the runner system variables?

P.S. I know that using $HOME in the script section like so would obviously work

  script:
    - export SOME_DIR=$HOME/some/dir

Not my area of expertise, but I think you might be able to achieve this by using two jobs, and saving the variable from the first one into a dotenv artifact.

See the example in Pass an environment variable to another job.