haskellPackages.ats-format: ignore custom Setup.hs, install manually

ats-format has a custom Setup.hs which does the following using cli-setup:

* Add ~/.local/share/man to $MANPATH by editing shell configurations in $HOME.

* Install a man page into ~/.local/share

* Install a shell completion by editing shell configurations in $HOME.

We had a workaround to keep this from failing the build in the nix sandbox, but
this seemingly broke on darwin. To fix this once and forall, we force the use
of only `defaultMain` in Setup.hs and install the man page manually.
Additionally we generate completions and remove unnecessary extra references
from the closure.
This commit is contained in:
sternenseemann 2021-08-06 02:46:16 +02:00 committed by sterni
parent 964abed995
commit c66cc62b6c
2 changed files with 25 additions and 6 deletions

View File

@ -1044,12 +1044,6 @@ self: super: {
# Has tasty < 1.2 requirement, but works just fine with 1.2
temporary-resourcet = doJailbreak super.temporary-resourcet;
# fake a home dir and capture generated man page
ats-format = overrideCabal super.ats-format (old : {
preConfigure = "export HOME=$PWD";
postBuild = "mv .local/share $out";
});
# Test suite doesn't work with current QuickCheck
# https://github.com/pruvisto/heap/issues/11
heap = dontCheck super.heap;

View File

@ -919,4 +919,29 @@ self: super: builtins.intersectAttrs super {
# Flag added in Agda 2.6.2
Agda = appendConfigureFlag super.Agda "-foptimise-heavily";
# ats-format uses cli-setup in Setup.hs which is quite happy to write
# to arbitrary files in $HOME. This doesn't either not achieve anything
# or even fail, so we prevent it and install everything necessary ourselves.
# See also: https://hackage.haskell.org/package/cli-setup-0.2.1.4/docs/src/Distribution.CommandLine.html#setManpathGeneric
ats-format = generateOptparseApplicativeCompletion "atsfmt" (
justStaticExecutables (
overrideCabal super.ats-format (drv: {
# use vanilla Setup.hs
preCompileBuildDriver = ''
cat > Setup.hs << EOF
module Main where
import Distribution.Simple
main = defaultMain
EOF
'' + (drv.preCompileBuildDriver or "");
# install man page
buildTools = [
pkgs.buildPackages.installShellFiles
] ++ (drv.buildTools or []);
postInstall = ''
installManPage man/atsfmt.1
'' + (drv.postInstall or "");
})
)
);
}