From a9fad501813562d08096440fb466a1ccd623de97 Mon Sep 17 00:00:00 2001 From: Peter Simons Date: Sat, 16 Aug 2014 17:37:16 +0200 Subject: [PATCH] cabal: minor code re-factoring of shleavy's patch that allows building packages without a Setup.hs file https://github.com/NixOS/nixpkgs/pull/3585 --- pkgs/build-support/cabal/default.nix | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkgs/build-support/cabal/default.nix b/pkgs/build-support/cabal/default.nix index 7147b287fae..0669b85c724 100644 --- a/pkgs/build-support/cabal/default.nix +++ b/pkgs/build-support/cabal/default.nix @@ -18,6 +18,11 @@ let optionals = stdenv.lib.optionals; optionalString = stdenv.lib.optionalString; filter = stdenv.lib.filter; + + defaultSetupHs = builtins.toFile "Setup.hs" '' + import Distribution.Simple + main = defaultMain + ''; in # Cabal shipped with GHC 6.12.4 or earlier doesn't know the "--enable-tests configure" flag. @@ -179,15 +184,10 @@ assert !enableStaticLibraries -> versionOlder "7.7" ghc.version; ${optionalString self.jailbreak "${jailbreakCabal}/bin/jailbreak-cabal ${self.pname}.cabal"} - for i in Setup.hs Setup.lhs; do - test -f $i && ghc --make $i + for i in Setup.hs Setup.lhs ${defaultSetupHs}; do + test -f $i && break done - if [ ! -f Setup ]; then - ghc --make ${builtins.toFile "Setup.hs" '' - import Distribution.Simple - main = defaultMain - ''} -o Setup -odir $TMPDIR - fi + ghc --make -o Setup -odir $TMPDIR $i for p in $extraBuildInputs $propagatedNativeBuildInputs; do if [ -d "$p/lib/ghc-${ghc.ghc.version}/package.conf.d" ]; then