on e94de40 help sign in
68 lines 2.0 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-simple.doHaddock = false;
12 }
13 ];
15 project = project' {
16 inherit compiler-nix-name;
17 src = testSrc "cabal-simple";
18 inherit modules;
19 };
21 packages = project.hsPkgs;
23in recurseIntoAttrs {
24 ifdInputs = {
25 inherit (project) plan-nix;
26 };
28 # Used for testing externally with nix-shell (../tests.sh).
29 test-shell = packages.shellFor { tools = { cabal = "3.2.0.0"; }; };
31 run = stdenv.mkDerivation {
32 name = "cabal-simple-test";
34 buildCommand = ''
35 exe="${packages.cabal-simple.components.exes.cabal-simple}/bin/cabal-simple${stdenv.hostPlatform.extensions.executable}"
37 size=$(command stat --format '%s' "$exe")
38 printf "size of executable $exe is $size. \n" >& 2
40 # fixme: run on target platform when cross-compiled
41 printf "checking whether executable runs... " >& 2
42 cat ${haskellLib.check packages.cabal-simple.components.exes.cabal-simple}/test-stdout
43 '' + (if stdenv.hostPlatform.isMusl
44 then ''
45 printf "checking that executable is statically linked... " >& 2
46 (ldd $exe 2>&1 || true) | grep -i "not a"
47 ''
48 else
49 # Skip this on aarch as we do not have an `ldd` tool
50 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
51 printf "checking that executable is dynamically linked to system libraries... " >& 2
52 '' + optionalString stdenv.isLinux ''
53 ldd $exe | grep libpthread
54 '' + optionalString stdenv.isDarwin ''
55 otool -L $exe |grep .dylib
56 '')) + ''
58 touch $out
59 '';
61 meta.platforms = platforms.all;
63 passthru = {
64 # Used for debugging with nix repl
65 inherit project packages;
66 };
67 };