It seems in cabal-install-1.24 that commands like register and sdist now require the create of a ~/.cabal/config file which fails during nix builds.
See this bug for details:
https://github.com/NixOS/nixpkgs/issues/16144
At the core, it seems that loadConifg requires the creation of a ~/.cabal/config if such a file does not exist. While that has been the case for a while, changes made by this patch,
https://github.com/haskell/cabal/commit/3bb8c7a9a2499dc2a06325d290628a8c7d8ab6bf#diff-53e6b83dd13dd8fb7781bc0ce3e6b36bL282
caused more commands to be affected by it. It's not clear that is a 'bug' -- but it does seems to cause trouble anyway.
Paradoxically, the patch author @ttuegel is a significant nixpkgs contributor.
That is actually a good thing, because I think solving this problem requires understanding both sides pretty well.
Most commands now invoke loadConfigOrSandboxConfig to find distPref which requires the user cabal configuration file to exist. For most purposes, it would be sufficient to assume an empty configuration if the file does not exist, and this is what we should do.
@stepcut Could you try #3500 and see if it solves the issue?
Most helpful comment
Paradoxically, the patch author @ttuegel is a significant nixpkgs contributor.