From c66cc62b6c61ba745e2baf51c41a50970a08d508 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 6 Aug 2021 02:46:16 +0200 Subject: [PATCH] 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. --- .../haskell-modules/configuration-common.nix | 6 ----- .../haskell-modules/configuration-nix.nix | 25 +++++++++++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 4b958c997a78..5d29d8554c0e 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -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; diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index ef0bd0656ffd..8cd325db9063 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -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 ""); + }) + ) + ); }