haskell.nix/test/cabal-simple-debug/default.nix
2022-07-31 21:41:50 +12:00

53 lines
1.5 KiB
Nix

# Test a package set
{ stdenv, lib, util, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages, dwarfdump }:
with lib;
let
project = cabalProject' {
inherit compiler-nix-name evalPackages;
src = testSrc "cabal-simple-debug";
cabalProject = ''
packages: .
allow-newer: aeson:*
'';
};
packages = project.hsPkgs;
in recurseIntoAttrs {
# DWARF only works on linux with GHC 8.10.2 and newer
# GHC 9.2.1 disabled because of https://github.com/input-output-hk/haskell.nix/issues/1332
meta.disabled = __elem compiler-nix-name ["ghc865" "ghc884" "ghc921" "ghc922" "ghc923" "ghc924"]
|| !stdenv.hostPlatform.isLinux || haskellLib.isCrossHost || stdenv.hostPlatform.isMusl;
ifdInputs = {
inherit (project) plan-nix;
};
run = stdenv.mkDerivation {
name = "cabal-simple-debug-test";
buildCommand = ''
exe="${(packages.cabal-simple.components.exes.cabal-simple.dwarf).exePath}"
size=$(command stat --format '%s' "$exe")
printf "size of executable $exe is $size. \n" >& 2
# fixme:
printf "checking whether executable included DWARF debug info... " >& 2
(${dwarfdump}/bin/dwarfdump $exe || true) | grep -c 'libraries/base/[A-Za-z0-9/]*\.hs'
(${dwarfdump}/bin/dwarfdump $exe || true) | grep -c '\/Main\.hs'
touch $out
'';
meta = {
platforms = platforms.all;
};
passthru = {
# Used for debugging with nix repl
inherit project packages;
};
};
}