on 19052d8 help sign in
57 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 };
12 packages = project.hsPkgs;
14in recurseIntoAttrs {
15 # Haddock is not included with cross compilers currently
16 meta.disabled = haskellLib.isCrossHost;
17 ifdInputs = {
18 inherit (project) plan-nix;
19 };
20 run = stdenv.mkDerivation {
21 name = "sublib-docs-test";
23 buildCommand = ''
24 exe="${packages.sublib-docs.components.exes.sublib-docs.exePath}"
26 size=$(command stat --format '%s' "$exe")
27 printf "size of executable $exe is $size. \n" >& 2
29 # fixme: run on target platform when cross-compiled
30 printf "checking whether executable runs... " >& 2
31 cat ${haskellLib.check packages.sublib-docs.components.exes.sublib-docs}/test-stdout
33 '' +
34 # Musl and Aarch are statically linked..
35 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
36 printf "checking that executable is dynamically linked to system libraries... " >& 2
37 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
38 ldd $exe | grep libgmp
39 '' + optionalString stdenv.isDarwin ''
40 otool -L $exe |grep .dylib
41 '') + ''
43 # Check that it looks like we have docs
44 test -f "${packages.sublib-docs.components.library.doc}/share/doc/sublib-docs/html/Lib.html"
45 test -f "${packages.sublib-docs.components.sublibs.slib.doc}/share/doc/slib/html/Slib.html"
47 touch $out
48 '';
50 meta.platforms = platforms.all;
52 passthru = {
53 # Used for debugging with nix repl
54 inherit packages;
55 };
56 };