# Test a package set { stdenv, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name }: with stdenv.lib; let modules = [ { # Package has no exposed modules which causes # haddock: No input file(s) packages.cabal-sublib.doHaddock = false; } ]; # The ./pkgs.nix works for linux & darwin, but not for windows project = cabalProject' { inherit compiler-nix-name; src = testSrc "cabal-sublib"; inherit modules; }; packages = project.hsPkgs; in recurseIntoAttrs { ifdInputs = { inherit (project) plan-nix; }; run = stdenv.mkDerivation { name = "cabal-sublib-test"; buildCommand = '' exe="${packages.cabal-sublib.components.exes.cabal-sublib}/bin/cabal-sublib${stdenv.hostPlatform.extensions.executable}" size=$(command stat --format '%s' "$exe") printf "size of executable $exe is $size. \n" >& 2 # fixme: run on target platform when cross-compiled printf "checking whether executable runs... " >& 2 cat ${haskellLib.check packages.cabal-sublib.components.exes.cabal-sublib}/test-stdout '' + # Musl and Aarch are statically linked.. optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64 && !stdenv.hostPlatform.isMusl) ('' printf "checking that executable is dynamically linked to system libraries... " >& 2 '' + optionalString (stdenv.isLinux && !stdenv.hostPlatform.isMusl) '' ldd $exe | grep libgmp '' + optionalString stdenv.isDarwin '' otool -L $exe |grep .dylib '') + '' touch $out ''; meta.platforms = platforms.all; passthru = { # Used for debugging with nix repl inherit packages; }; }; }