haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

Builder doesn't run Setup.hs hooks (autoreconf etc.)

Open thomasjm opened this issue 5 years ago • 3 comments

I have a project that needs you to run autoreconf -i to generate a configure script before it can be built. Building it works fine with normal stack/cabal but it doesn't work with haskell.nix.

My repo is here: https://github.com/codedownio/statvfs/tree/38fcb950982525aa1737418685cd8fca2f7452e2. You can try running nix-build -A statvfs.components.library to see the problem.

Setup.hs just invokes autoconfUserHooks:

module Main (main) where

import Distribution.Simple

main :: IO ()
main = defaultMainWithHooks autoconfUserHooks

I get the following error:

Warning: The 'build-type' is 'Configure' but there is no 'configure' script.
You probably need to run 'autoreconf -i' to generate it.
Setup: configure script not found.

Installing an override as mentioned in https://github.com/input-output-hk/haskell.nix/issues/768 worked, but I think this should be automatic:

  modules = [
    {
      packages.statvfs.components.library.preConfigure = ''
        ${pkgs.autoconf}/bin/autoreconf -i
      '';
    }
  ];

thomasjm avatar Jul 22 '20 09:07 thomasjm

Another example of this; old-time requires autoreconf -i: https://github.com/peterbecich/old-time/tree/build-with-nix

nix build -f default.nix
...
       > Configuring library for old-time-1.1.0.3..
       > Warning: The flag --disable-executable-profiling is deprecated. Please use
       > --disable-profiling instead.
       > Warning: The 'build-type' is 'Configure' but there is no 'configure' script.
       > You probably need to run 'autoreconf -i' to generate it.
       > Setup: configure script not found.
       >
       For full logs, run 'nix log /nix/store/0az17fxv89gyciiykr3a05q50ay0q76c-old-time-lib-old-time-1.1.0.3.drv'.
error: 1 dependencies of derivation '/nix/store/5bcf2csq9652rjz0ns5hr3dqzfqzwl46-project-coverage-report.drv' failed to build
error: build of '/nix/store/325whvhzfvw62s99ldq1g421kiym291b-ghc-shell-for-old-time.drv', '/nix/store/5bcf2csq9652rjz0ns5hr3dqzfqzwl46-project-coverage-report.drv' failed

Copying the post above, this override fixes it: https://github.com/peterbecich/old-time/blob/6d1b00c6353c574af8d4f517d54ea70668ff4cf2/default.nix#L16-L22

peterbecich avatar Nov 07 '21 03:11 peterbecich

Is this related to the issue? https://github.com/input-output-hk/haskell.nix/blob/3b81b5b0618c10589ba0de0c3208dd7087f16e04/builder/setup-builder.nix https://github.com/input-output-hk/haskell.nix/blob/3b81b5b0618c10589ba0de0c3208dd7087f16e04/builder/setup-builder.nix#L70

and/or this? https://nixos.org/manual/nixpkgs/stable/#setup-hook-autoconf

peterbecich avatar Nov 07 '21 03:11 peterbecich

I believe this also prevents the network library from building successfully with haskell.nix and GHCJS.

Some of these essential extra-source-files are not checked into version control: https://github.com/haskell/network/blob/53519f0ff9f282b69fa67a9b32c3a4e61bf8478b/network.cabal#L40-L47 When building network with haskell.nix and GHCJS, this results in errors such as:

> cabal: sdist of network-3.1.2.7: filepath wildcard 'configure' does not match any files.
> cabal: sdist of network-3.1.2.7: filepath wildcard 'include/HsNetworkConfig.h.in' does not match any files.

By itself the network library does support building with GHCJS: https://github.com/haskell/network/pull/431


As an aside, there is another issue with building network using haskell.nix and GHCJS, which should be solved separately: https://github.com/haskell/network/commit/80ea53f81a81193403cb9d3445cd874232455696#diff-9c966208fd0a0c8e24a1526da6904887c378283b9b645b9740c19339884174d9R1753

peterbecich avatar Jun 12 '22 06:06 peterbecich