This closes#79441.
ghcWithPackages is using `ghc-pkg recache` to build its package
database. By doing so, it overrides the `package.cache[.lock]` files.
Details are unclear, but GHC 8.10 changed a bit the behavior.
Previously, it was unconditionally replacing the files by new ones. Now
it tries to open (for modification) the files. These files are symlinks
to another nix derivation, which is hence read-only.
This commit removes the files before running `ghc-pkg recache`, hence it
will just write the new files.
Tested with `haskellPackages.ghcWithPackages` (i.e. GHC 8.8) and
`haskell.packages.ghc8101.ghcWithPackages` (i.e GHC 8.10) with the
following nix file, at the root of the nixpkgs repository:
```
with import ./. {
overlays = [
(
self: super: {
haskellPackages = super.haskell.packages.ghc8101.override {
overrides = selfh: superh: {
th-lift-instances = super.haskell.lib.doJailbreak superh.th-lift-instances;
th-expand-syns = super.haskell.lib.doJailbreak superh.th-expand-syns;
th-reify-many = super.haskell.lib.doJailbreak superh.th-reify-many;
th-orphans = super.haskell.lib.doJailbreak superh.th-orphans;
haskell-src-meta = super.haskell.lib.doJailbreak superh.haskell-src-meta;
};
};
}
)
];
};
haskellPackages.ghcWithPackages(p:[p.PyF])
```
This will test with GHC 8.10. Comment out the `overlays` to test with
GHC 8.8.
The configuration-tensorflow.nix file specified several overrides for version
0.2.x packages, but those packages are no longer included in our package set
because they are so old. (Current versions seem to be in the range of 0.6.x.)
I fixed the evalution errors, but I did not verify whether these packages
actually build with the newer versions.
I checked through haskellPackages looking for packages that were
marked as broken, but successfully built.
I identified these 162 packages that were marked as broken in spite of
building successfully for me with NIXPKGS_ALLOW_BROKEN.
`cabal2nix` fails to evaluate due to attempting to
evaluate `pkgs.haskellPackages.hackage-db_2_1_0`, which
does not exist. However, the default
`pkgs.haskellPackages.hackage-db` is already version 2.1.0,
so the fix is simple: go back to using the default version.