on e94de40 help sign in
65 lines 1.9 kB history raw
1# Test a package set
2{ stdenv, util, mkCabalProjectPkgSet, project', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }:
4with stdenv.lib;
6let
7 modules = [
8 {
9 # Package has no exposed modules which causes
10 # haddock: No input file(s)
11 packages.cabal-hpack.doHaddock = false;
12 }
13 ];
15 project = project' {
16 inherit compiler-nix-name;
17 src = testSrc "cabal-hpack";
18 inherit modules;
19 };
21 packages = project.hsPkgs;
23in recurseIntoAttrs {
24 ifdInputs = {
25 inherit (project) plan-nix;
26 };
28 run = stdenv.mkDerivation {
29 name = "cabal-hpack-test";
31 buildCommand = ''
32 exe="${packages.cabal-hpack.components.exes.cabal-hpack}/bin/cabal-hpack${stdenv.hostPlatform.extensions.executable}"
34 size=$(command stat --format '%s' "$exe")
35 printf "size of executable $exe is $size. \n" >& 2
37 # fixme: run on target platform when cross-compiled
38 printf "checking whether executable runs... " >& 2
39 cat ${haskellLib.check packages.cabal-hpack.components.exes.cabal-hpack}/test-stdout
40 '' + (if stdenv.hostPlatform.isMusl
41 then ''
42 printf "checking that executable is statically linked... " >& 2
43 (ldd $exe 2>&1 || true) | grep -i "not a"
44 ''
45 else
46 # Skip this on aarch as we do not have an `ldd` tool
47 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
48 printf "checking that executable is dynamically linked to system libraries... " >& 2
49 '' + optionalString stdenv.isLinux ''
50 ldd $exe | grep libpthread
51 '' + optionalString stdenv.isDarwin ''
52 otool -L $exe |grep .dylib
53 '')) + ''
55 touch $out
56 '';
58 meta.platforms = platforms.all;
60 passthru = {
61 # Used for debugging with nix repl
62 inherit project packages;
63 };
64 };