on fa2fa13 help sign in
61 lines 1.8 kB history raw
1# Test a package set
2{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }:
4with lib;
6let
7 project = cabalProject' {
8 inherit compiler-nix-name;
9 src = testSrc "sublib-docs";
10 cabalProject = ''
11 packages: .
12 allow-newer: aeson:*
13 '';
14 };
16 packages = project.hsPkgs;
18in recurseIntoAttrs {
19 # Haddock is not included with cross compilers currently
20 meta.disabled = haskellLib.isCrossHost;
21 ifdInputs = {
22 inherit (project) plan-nix;
23 };
24 run = stdenv.mkDerivation {
25 name = "sublib-docs-test";
27 buildCommand = ''
28 exe="${packages.sublib-docs.components.exes.sublib-docs.exePath}"
30 size=$(command stat --format '%s' "$exe")
31 printf "size of executable $exe is $size. \n" >& 2
33 # fixme: run on target platform when cross-compiled
34 printf "checking whether executable runs... " >& 2
35 cat ${haskellLib.check packages.sublib-docs.components.exes.sublib-docs}/test-stdout
37 '' +
38 # Musl and Aarch are statically linked..
39 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
40 printf "checking that executable is dynamically linked to system libraries... " >& 2
41 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
42 ldd $exe | grep libgmp
43 '' + optionalString stdenv.isDarwin ''
44 otool -L $exe |grep .dylib
45 '') + ''
47 # Check that it looks like we have docs
48 test -f "${packages.sublib-docs.components.library.doc}/share/doc/sublib-docs/html/Lib.html"
49 test -f "${packages.sublib-docs.components.sublibs.slib.doc}/share/doc/slib/html/Slib.html"
51 touch $out
52 '';
54 meta.platforms = platforms.all;
56 passthru = {
57 # Used for debugging with nix repl
58 inherit packages;
59 };
60 };