Files
nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

52 lines
1.0 KiB
Nix

{ pkgs, haskellPackages }:
let
# This can be regenerated by running `cabal2nix ./src` in the current directory.
pkgDef =
{
mkDerivation,
base,
lib,
}:
mkDerivation {
pname = "haskell-setBuildTarget";
version = "0.1.0.0";
src = ./src;
isLibrary = false;
isExecutable = true;
executableHaskellDepends = [ base ];
license = pkgs.lib.licenses.mit;
};
drv = haskellPackages.callPackage pkgDef { };
test =
target: excluded:
let
only = pkgs.haskell.lib.compose.setBuildTarget target drv;
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.compose.setBuildTarget"
{
meta = {
inherit (drv.meta) platforms;
};
}
''
${test "foo" "bar"}
${test "bar" "foo"}
touch "$out"
''