2021-05-20 23:08:51 +00:00
|
|
|
{ pkgs, haskellPackages }:
|
|
|
|
|
|
|
|
let
|
|
|
|
# This can be regenerated by running `cabal2nix .` in the current directory.
|
|
|
|
pkgDef =
|
|
|
|
{ mkDerivation, base, lib }:
|
|
|
|
mkDerivation {
|
|
|
|
pname = "haskell-setBuildTarget";
|
|
|
|
version = "0.1.0.0";
|
|
|
|
src = ./.;
|
|
|
|
isLibrary = false;
|
|
|
|
isExecutable = true;
|
|
|
|
executableHaskellDepends = [ base ];
|
|
|
|
license = lib.licenses.bsd3;
|
|
|
|
};
|
|
|
|
|
|
|
|
drv = haskellPackages.callPackage pkgDef {};
|
|
|
|
|
|
|
|
test = target: excluded:
|
2021-12-06 16:07:01 +00:00
|
|
|
let only = pkgs.haskell.lib.compose.setBuildTarget target drv;
|
2021-05-20 23:08:51 +00:00
|
|
|
in ''
|
|
|
|
if [[ ! -f "${only}/bin/${target}" ]]; then
|
|
|
|
echo "${target} was not built"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f "${only}/bin/${excluded}" ]]; then
|
|
|
|
echo "${excluded} was built, when it should not have been"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2021-07-17 21:14:59 +00:00
|
|
|
in
|
2021-12-06 16:07:01 +00:00
|
|
|
pkgs.runCommand "test haskell.lib.compose.setBuildTarget" {
|
2021-07-17 21:14:59 +00:00
|
|
|
meta = {
|
|
|
|
inherit (drv.meta) platforms;
|
|
|
|
};
|
|
|
|
} ''
|
2021-05-20 23:08:51 +00:00
|
|
|
${test "foo" "bar"}
|
|
|
|
${test "bar" "foo"}
|
|
|
|
touch "$out"
|
|
|
|
''
|
|
|
|
|