Access system stateVersion variable in nix-shell expression

Is it possible to somehow access the system.stateVersion variable from within a nix-shell profile expression?
I would like to use a package dependent on it.

I tried (import (pkgs.path + /config) { configuration = {}; }).config.system.stateVersion, but it does not return the version defined in my system config (21.5), but returns a later version instead (21.11).

I found that I can call the config using this snippet:
(pkgs.callPackage /etc/nixos/configuration.nix {}).system.stateVersion

But that does not work if the config was changed without the system being rebuilt.

(import <nixpkgs/nixos> {}).config.system.stateVersion seems to be what I was looking for.