on e94de40 help sign in
55 lines 1.7 kB history raw
1# Test a package set
2{ stdenv, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }:
4with stdenv.lib;
6let
7 project = cabalProject' {
8 inherit compiler-nix-name;
9 src = testSrc "sublib-docs";
10 };
12 packages = project.hsPkgs;
14in recurseIntoAttrs {
15 ifdInputs = {
16 inherit (project) plan-nix;
17 };
18 run = stdenv.mkDerivation {
19 name = "sublib-docs-test";
21 buildCommand = ''
22 exe="${packages.sublib-docs.components.exes.sublib-docs}/bin/sublib-docs${stdenv.hostPlatform.extensions.executable}"
24 size=$(command stat --format '%s' "$exe")
25 printf "size of executable $exe is $size. \n" >& 2
27 # fixme: run on target platform when cross-compiled
28 printf "checking whether executable runs... " >& 2
29 cat ${haskellLib.check packages.sublib-docs.components.exes.sublib-docs}/test-stdout
31 '' +
32 # Musl and Aarch are statically linked..
33 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
34 printf "checking that executable is dynamically linked to system libraries... " >& 2
35 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
36 ldd $exe | grep libgmp
37 '' + optionalString stdenv.isDarwin ''
38 otool -L $exe |grep .dylib
39 '') + ''
41 # Check that it looks like we have docs
42 test -f "${packages.sublib-docs.components.library.doc}/share/doc/sublib-docs/html/Lib.html"
43 test -f "${packages.sublib-docs.components.sublibs.slib.doc}/share/doc/slib/html/Slib.html"
45 touch $out
46 '';
48 meta.platforms = platforms.all;
50 passthru = {
51 # Used for debugging with nix repl
52 inherit packages;
53 };
54 };