Interpolating {{ .Environment.SOME_VAR }} after setting SOME_VAR results in "<no value>"

Using this configuration:

version: 2
jobs:
  test:
    docker:
    - image: nixorg/nix:circleci
    environment:
      NIXPKGS_REV: 3c83ad6ac13b67101cc3e2e07781963a010c1624
    steps:
    - run:
        name: Setup NIX_PATH Environment Variable
        command: |
          echo "export NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/$NIXPKGS_REV.tar.gz" >> $BASH_ENV
    - restore_cache:
        name: Restore Nix Store Paths
        keys:
        - paymentserver-nix-store-v1-{{ .Environment.NIXPKGS_REV }}
        - paymentserver-nix-store-v1-

The job tries to restore the cache using the key paymentserver-nix-store-v1-<no value>.

https://circleci.com/docs/2.0/env-vars/#setting-an-environment-variable-in-a-job says this is the correct way to set an environment variable. https://circleci.com/docs/2.0/caching/#using-keys-and-templates says interpolating environment variables this way is supported for cache keys.

What’s going on? How do I use the value of an environment variable in a cache key?

Thanks.

It seems this is just a limitation of CircleCI. More details and my work-around at https://devops.stackexchange.com/questions/9147/how-to-get-other-than-no-value-when-interpolating-environment-some-var/9177