2022-07-28 11:03:05 +03:00
|
|
|
{ stdenv, lib, cabalProject', haskellLib, recurseIntoAttrs, testSrc, compiler-nix-name, evalPackages }:
|
2020-05-02 13:16:34 +03:00
|
|
|
|
2021-02-10 15:07:16 +03:00
|
|
|
with lib;
|
2020-05-02 13:16:34 +03:00
|
|
|
|
2020-08-31 02:08:25 +03:00
|
|
|
let
|
|
|
|
|
2020-05-02 13:16:34 +03:00
|
|
|
hackage = import ./hackage;
|
|
|
|
|
2022-02-17 14:42:11 +03:00
|
|
|
tarballs = {
|
|
|
|
extra-hackage-demo = ./01-index.tar.gz;
|
2020-05-02 13:16:34 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
demo-src = ./external-package-demo-0.1.0.0.tar.gz;
|
|
|
|
|
|
|
|
project = cabalProject' {
|
2022-07-28 11:03:05 +03:00
|
|
|
inherit compiler-nix-name evalPackages;
|
2020-05-02 13:16:34 +03:00
|
|
|
src = testSrc "extra-hackage/external-package-user";
|
|
|
|
|
|
|
|
extra-hackages = [ hackage ];
|
2022-02-17 14:42:11 +03:00
|
|
|
extra-hackage-tarballs = tarballs;
|
2020-05-02 13:16:34 +03:00
|
|
|
|
|
|
|
modules = [
|
|
|
|
# To prevent nix-build from trying to download it from the
|
|
|
|
# actual Hackage.
|
|
|
|
{ packages.external-package-demo.src = demo-src; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
packages = project.hsPkgs;
|
|
|
|
|
2020-07-08 13:54:01 +03:00
|
|
|
in recurseIntoAttrs {
|
2020-05-02 13:16:34 +03:00
|
|
|
ifdInputs = {
|
|
|
|
inherit (project) plan-nix;
|
|
|
|
};
|
|
|
|
run = stdenv.mkDerivation {
|
|
|
|
name = "external-hackage-test";
|
|
|
|
|
|
|
|
buildCommand = ''
|
2020-11-17 12:22:53 +03:00
|
|
|
exe="${packages.external-package-user.components.exes.external-package-user.exePath}"
|
2020-05-02 13:16:34 +03:00
|
|
|
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
|
2020-09-29 06:56:24 +03:00
|
|
|
cat ${haskellLib.check packages.external-package-user.components.exes.external-package-user}/test-stdout
|
2020-05-02 13:16:34 +03:00
|
|
|
'' + (if stdenv.hostPlatform.isMusl
|
|
|
|
then ''
|
|
|
|
printf "checking that executable is statically linked... " >& 2
|
|
|
|
(ldd $exe 2>&1 || true) | grep -i "not a"
|
|
|
|
''
|
|
|
|
else
|
|
|
|
# Skip this on aarch as we do not have an `ldd` tool
|
|
|
|
optionalString (!stdenv.hostPlatform.isAarch32 && !stdenv.hostPlatform.isAarch64) (''
|
|
|
|
printf "checking that executable is dynamically linked to system libraries... " >& 2
|
|
|
|
'' + optionalString stdenv.isLinux ''
|
2022-07-17 09:18:19 +03:00
|
|
|
ldd $exe | grep 'libc\.so'
|
2020-05-02 13:16:34 +03:00
|
|
|
'' + optionalString stdenv.isDarwin ''
|
|
|
|
otool -L $exe |grep .dylib
|
|
|
|
'')) + ''
|
|
|
|
touch $out
|
2020-08-31 02:08:25 +03:00
|
|
|
'';
|
2020-05-02 13:16:34 +03:00
|
|
|
meta.platforms = platforms.all;
|
|
|
|
passthru = {
|
|
|
|
inherit project;
|
2020-08-31 02:08:25 +03:00
|
|
|
};
|
2020-05-02 13:16:34 +03:00
|
|
|
};
|
2020-07-08 13:54:01 +03:00
|
|
|
}
|