on e94de40 help sign in
66 lines 2.1 kB history raw
1{ stdenv, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }:
3with stdenv.lib;
5let
7 hackage = import ./hackage;
9 tarball = {
10 name = "extra-hackage-demo";
11 index = ./01-index.tar.gz;
12 };
14 demo-src = ./external-package-demo-0.1.0.0.tar.gz;
16 project = cabalProject' {
17 inherit compiler-nix-name;
18 src = testSrc "extra-hackage/external-package-user";
20 extra-hackages = [ hackage ];
21 extra-hackage-tarballs = [ tarball ];
23 modules = [
24 # To prevent nix-build from trying to download it from the
25 # actual Hackage.
26 { packages.external-package-demo.src = demo-src; }
27 ];
28 };
29 packages = project.hsPkgs;
31in recurseIntoAttrs {
32 ifdInputs = {
33 inherit (project) plan-nix;
34 };
35 run = stdenv.mkDerivation {
36 name = "external-hackage-test";
38 buildCommand = ''
39 exe="${packages.external-package-user.components.exes.external-package-user}/bin/external-package-user${stdenv.hostPlatform.extensions.executable}"
40 size=$(command stat --format '%s' "$exe")
41 printf "size of executable $exe is $size. \n" >& 2
42 # fixme: run on target platform when cross-compiled
43 printf "checking whether executable runs... " >& 2
44 cat ${haskellLib.check packages.external-package-user.components.exes.external-package-user}/test-stdout
45 '' + (if stdenv.hostPlatform.isMusl
46 then ''
47 printf "checking that executable is statically linked... " >& 2
48 (ldd $exe 2>&1 || true) | grep -i "not a"
49 ''
50 else
51 # Skip this on aarch as we do not have an `ldd` tool
52 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
53 printf "checking that executable is dynamically linked to system libraries... " >& 2
54 '' + optionalString stdenv.isLinux ''
55 ldd $exe | grep libpthread
56 '' + optionalString stdenv.isDarwin ''
57 otool -L $exe |grep .dylib
58 '')) + ''
59 touch $out
60 '';
61 meta.platforms = platforms.all;
62 passthru = {
63 inherit project;
64 };
65 };