diff options
Diffstat (limited to 'nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix')
-rw-r--r-- | nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix b/nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix new file mode 100644 index 000000000000..b1335e2a74cf --- /dev/null +++ b/nixpkgs/pkgs/test/haskell/setBuildTarget/default.nix @@ -0,0 +1,38 @@ +{ 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: + let only = pkgs.haskell.lib.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" +'' + |