nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 runCommand,
4 runCommandCC,
5 haskellPackages,
6}:
7
8lib.recurseIntoAttrs {
9 # This is special-cased to return just `ghc`.
10 trivial = haskellPackages.ghcWithPackages (hsPkgs: [ ]);
11
12 # Here we actually build a trivial package.
13 hello = haskellPackages.ghcWithPackages (hsPkgs: [
14 hsPkgs.hello
15 ]);
16
17 # Here we build a database with multiple packages.
18 multiple = haskellPackages.ghcWithPackages (hsPkgs: [
19 hsPkgs.hspec
20 hsPkgs.unordered-containers
21 ]);
22
23 # See: https://github.com/NixOS/nixpkgs/pull/224542
24 regression-224542 =
25 let
26 ghc = haskellPackages.ghcWithPackages (hsPkgs: [
27 hsPkgs.hspec
28 ]);
29 in
30 runCommand "regression-224542"
31 {
32 nativeBuildInputs = [
33 ghc
34 ];
35 }
36 ''
37 ${ghc.targetPrefix}ghc --interactive \
38 -Werror=unrecognised-warning-flags \
39 -Werror=missed-extra-shared-lib \
40 2>&1 \
41 | tee ghc-output.txt
42
43 # If GHC failed to find a shared library, linking dylibs in
44 # `ghcWithPackages` didn't work correctly.
45 if grep --quiet "error: .*-Wmissed-extra-shared-lib" ghc-output.txt \
46 && grep --quiet "no such file" ghc-output.txt; then
47 exit 1
48 fi
49
50 touch $out
51 '';
52
53 use-llvm =
54 let
55 ghc = (haskellPackages.ghcWithPackages.override { useLLVM = true; }) (_: [ ]);
56 in
57 runCommandCC "ghc-with-packages-use-llvm"
58 {
59 nativeBuildInputs = [ ghc ];
60 }
61 ''
62 echo 'main = pure ()' > test.hs
63 # -ddump-llvm is unnecessary, but nice for visual feedback in the build log
64 ${ghc.targetPrefix}ghc --make -fllvm -keep-llvm-files -ddump-llvm test.hs
65 # Did we actually use the LLVM backend?
66 test -f test.ll
67 touch $out
68 '';
69}