diff --git a/pkgs/development/haskell-modules/with-packages-wrapper.nix b/pkgs/development/haskell-modules/with-packages-wrapper.nix index 6fb552d22c75..b683febeaf6c 100644 --- a/pkgs/development/haskell-modules/with-packages-wrapper.nix +++ b/pkgs/development/haskell-modules/with-packages-wrapper.nix @@ -178,7 +178,7 @@ else + postBuild; preferLocalBuild = true; passthru = { - inherit (ghc) version meta; + inherit (ghc) version meta targetPrefix; hoogle = hoogleWithPackages'; diff --git a/pkgs/test/haskell/ghcWithPackages/default.nix b/pkgs/test/haskell/ghcWithPackages/default.nix index c31721b9531e..aedcac0d2c91 100644 --- a/pkgs/test/haskell/ghcWithPackages/default.nix +++ b/pkgs/test/haskell/ghcWithPackages/default.nix @@ -1,6 +1,7 @@ { lib, runCommand, + runCommandCC, haskellPackages, }: @@ -21,16 +22,19 @@ lib.recurseIntoAttrs { # See: https://github.com/NixOS/nixpkgs/pull/224542 regression-224542 = + let + ghc = haskellPackages.ghcWithPackages (hsPkgs: [ + hsPkgs.hspec + ]); + in runCommand "regression-224542" { - buildInputs = [ - (haskellPackages.ghcWithPackages (hsPkgs: [ - hsPkgs.hspec - ])) + nativeBuildInputs = [ + ghc ]; } '' - ghc --interactive \ + ${ghc.targetPrefix}ghc --interactive \ -Werror=unrecognised-warning-flags \ -Werror=missed-extra-shared-lib \ 2>&1 \ @@ -45,4 +49,21 @@ lib.recurseIntoAttrs { touch $out ''; + + use-llvm = + let + ghc = (haskellPackages.ghcWithPackages.override { useLLVM = true; }) (_: [ ]); + in + runCommandCC "ghc-with-packages-use-llvm" + { + nativeBuildInputs = [ ghc ]; + } + '' + echo 'main = pure ()' > test.hs + # -ddump-llvm is unnecessary, but nice for visual feedback in the build log + ${ghc.targetPrefix}ghc --make -fllvm -keep-llvm-files -ddump-llvm test.hs + # Did we actually use the LLVM backend? + test -f test.ll + touch $out + ''; }