What's cabal trying to do here?

I’m trying to get a local build working, and I’m using Nix.
But quite often, I’ve encountered cabal errors like these:

cabal: Could not resolve dependencies:
[__0] trying: xmonad-tr- (user goal)
[__1] trying: xmonad-extras-0.15.3/installed-H1hUQQmcjgAFfVvYAs3jro
(dependency of xmonad-tr)
[__2] next goal: xmonad-ashesh (dependency of xmonad-tr)
[__2] rejecting: xmonad-ashesh-
(conflict: xmonad-extras =>
xmonad-contrib==0.16/installed-W9AgyfioI3Af2b3pBTxkz, xmonad-ashesh =>
[__2] fail (backjumping, conflict set: xmonad-ashesh, xmonad-extras,

My question here is, what does this error message mean?
It seems to me that cabal fails to find a satisfactory xmonad-contrib, but what does the /installed-* after the conflicting version mean? And also, aren’t the contrib versions here the same?

I suspect this might have happened because you have either installed packages using cabal install --lib ... in the global environment ~/.ghc/.../environments/default or you locally with cabal install --lib --package-env . ... which generates a .ghc.environment... file in your working directory.

If either of those files contain a specific version+hash of a library then cabal is forced to use that version+hash only, so if you later install another library with, for example, different ghc flags like -O (which then produces a different hash) then you might get errors like that.

Are you building a cabal project/package with its own .cabal file, or are you making standalone cabal install invocations?

Does xmonad-ashesh require its xmonad-contrib dependency with some special flag?

The former: a project with its own .cabal file.
xmonad-ashesh doesn’t really have any special flags for xmonad-contrib;
Here’s xmonad-ashesh.cabal

I see, however, I don’t have a ~/.ghc at all. I’m just running nix-shell --run 'cabal repl'

When a package has the same name and version but differs in the hash like in this case, usually it means that it has been compiled with different flags or that the configuration varies in some way.

The problem seems to be that both xmonad-ashesh and xmonad-extras are requiring are requiring the same version of xmonad-contrib, with different configurations. But I don’t see any likely cause in the .cabal file.

I see that the package that requires xmonad-ashesh is xmonad-tr. What’s in its .cabal file?

.ghc.environment files shouldn’t be the problem in this case, either. They can only be a problem for standalone invocations.

For the xmonad-tr cabal file, nothing jumps out as suspicious to me:

common common-build-depends
    , base-noprelude >=4.7 && <5
    , xmonad
    , xmonad-contrib
    , xmonad-extras 
    , xmonad-spotify
    , fdo-notify
    , xmonad-ashesh
    , time 
    , containers
    , hostname
    , text
    , protolude
    , data-default-class 

No flags etc.

If you use nix-shell --run 'cabal repl' then perhaps cabal and nix are mixing up packages. Do you have some ghcWithPackages ... in that shell.nix file? You should just be able to use nix-shell --run 'ghci' if all the required dependencies are listed in the shell.nix file. Maybe only some of the packages are listed in the nix file and then cabal tries to find the remaining packages, but encounters conflicts?