on e94de40 help sign in
61 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 modules = [
8 {
9 # Package has no exposed modules which causes
10 # haddock: No input file(s)
11 packages.cabal-sublib.doHaddock = false;
12 }
13 ];
15 # The ./pkgs.nix works for linux & darwin, but not for windows
16 project = cabalProject' {
17 inherit compiler-nix-name;
18 src = testSrc "cabal-sublib";
19 inherit modules;
20 };
22 packages = project.hsPkgs;
24in recurseIntoAttrs {
25 ifdInputs = {
26 inherit (project) plan-nix;
27 };
28 run = stdenv.mkDerivation {
29 name = "cabal-sublib-test";
31 buildCommand = ''
32 exe="${packages.cabal-sublib.components.exes.cabal-sublib}/bin/cabal-sublib${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-sublib.components.exes.cabal-sublib}/test-stdout
41 '' +
42 # Musl and Aarch are statically linked..
43 optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) (''
44 printf "checking that executable is dynamically linked to system libraries... " >& 2
45 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) ''
46 ldd $exe | grep libgmp
47 '' + optionalString stdenv.isDarwin ''
48 otool -L $exe |grep .dylib
49 '') + ''
51 touch $out
52 '';
54 meta.platforms = platforms.all;
56 passthru = {
57 # Used for debugging with nix repl
58 inherit packages;
59 };
60 };