Add haskell.lib.setBuiltTarget, and support non library compiling of a single target

This commit is contained in:
Isaac Shapira
2021-05-02 13:35:07 +09:00
committed by (cdep)illabout
parent 111151c4bc
commit d725ac7942
8 changed files with 69 additions and 1 deletions
@@ -0,0 +1,26 @@
{ pkgs, haskellPackages }: with pkgs.haskell.lib;
let
drv = haskellPackages.callCabal2nix "haskell-setBuildTarget" ./. {};
test = target: excluded:
let only = setBuildTarget drv target;
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
'';
in pkgs.runCommand "test haskell.lib.setBuildTarget" {} ''
${test "foo" "bar"}
${test "bar" "foo"}
touch "$out"
''