How to get other than "" when interpolating {{ .Environment.SOME_VAR }} (with SOME_VAR set) into cache key?
A closer reading of the documentation about using environment variables in cache keys reveals the issue (emphasis mine):


  The environment variable variableName (supports any environment variable exported by CircleCI or added to a specific Context—not any arbitrary environment variable).


"exported by CircleCI" seems to mean the list of mostly-CIRCLE_...-prefixed variables (documented as "Built-In Environment Variables") while (unsupported) "any arbitrary environment variable" includes variables set in an environment section in config.yml.

I ended up working around this limitation something like this:

jobs:
  build:
    docker:
      - image: "nixorg/nix:circleci"

    environment:
      NIXPKGS_REV: "3c83ad6ac13b67101cc3e2e07781963a010c1624"

    steps:
      - "run":
          name: "Prepare For Cache Key"
          command: |
            echo "${NIXPKGS_REV}" &gt; nixpkgs.rev

      - restore_cache:
          name: "Restore Nix Store Paths"
          keys:
            - paymentserver-nix-store-v1-{{ checksum "nixpkgs.rev" }}
            - paymentserver-nix-store-v1-


That is, instead of trying to use the value of NIXPKGS_REV from the environment in the cache key, an earlier step writes the value of that environment variable to a file and then the cache key is constructed using the checksum of that file.  Computing file checksums for use in cache keys is well supported so this produces a cache key which is derived from the value of the environment variable.  The key doesn't contain the value of the environment variable but since the key's only purpose is to be unique for certain unique inputs, using the checksum works just as well.