Use configured compiler for cabal sandbox hc-pkg
For most commands (e.g. `cabal install`), the `package-db` field in
`cabal.sandbox.config` is ignored, and the path is reconstructed
from the `prefix` and current compiler instead. This is arguably
the right behaviour, because the right package DB depends on the
arch/compiler, so it doesn't make sense to specify only one. This
commit makes `cabal sandbox hc-pkg` behave similarly, to avoid
invoking ghc-pkg on an incompatible package DB (fixes #1935).
Moreover, the compiler version to use is now picked up from the
most recently configured compiler, if any. Otherwise, the global
default compiler is used, as before.