summaryrefslogtreecommitdiff
path: root/pkgs/test/haskell/setBuildTarget
diff options
context:
space:
mode:
authorRobin Gloster <mail@glob.in>2021-05-24 09:55:24 -0500
committerRobin Gloster <mail@glob.in>2021-05-24 09:55:24 -0500
commit4bc5fbef9d159e143fb7e2c3231932e6e76f667c (patch)
treee2198f5c552e0667d838b8ec764ddb3a4d8f6dec /pkgs/test/haskell/setBuildTarget
parentjq: fix build with structured-attrs on darwin (diff)
parentMerge pull request #123802 from superherointj/package-virtmanager-bugfix (diff)
downloadnixpkgs-origin/structured-attrs.tar.gz
Merge remote-tracking branch 'upstream/master' into structured-attrsorigin/structured-attrs
Diffstat (limited to 'pkgs/test/haskell/setBuildTarget')
-rw-r--r--pkgs/test/haskell/setBuildTarget/Bar.hs4
-rw-r--r--pkgs/test/haskell/setBuildTarget/Foo.hs4
-rw-r--r--pkgs/test/haskell/setBuildTarget/Setup.hs2
-rw-r--r--pkgs/test/haskell/setBuildTarget/default.nix38
-rw-r--r--pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal16
5 files changed, 64 insertions, 0 deletions
diff --git a/pkgs/test/haskell/setBuildTarget/Bar.hs b/pkgs/test/haskell/setBuildTarget/Bar.hs
new file mode 100644
index 000000000000..010014082c7d
--- /dev/null
+++ b/pkgs/test/haskell/setBuildTarget/Bar.hs
@@ -0,0 +1,4 @@
+module Main where
+
+main :: IO ()
+main = putStrLn "Hello, Bar!"
diff --git a/pkgs/test/haskell/setBuildTarget/Foo.hs b/pkgs/test/haskell/setBuildTarget/Foo.hs
new file mode 100644
index 000000000000..fec7bb11fe6c
--- /dev/null
+++ b/pkgs/test/haskell/setBuildTarget/Foo.hs
@@ -0,0 +1,4 @@
+module Main where
+
+main :: IO ()
+main = putStrLn "Hello, Foo!"
diff --git a/pkgs/test/haskell/setBuildTarget/Setup.hs b/pkgs/test/haskell/setBuildTarget/Setup.hs
new file mode 100644
index 000000000000..9a994af677b0
--- /dev/null
+++ b/pkgs/test/haskell/setBuildTarget/Setup.hs
@@ -0,0 +1,2 @@
+import Distribution.Simple
+main = defaultMain
diff --git a/pkgs/test/haskell/setBuildTarget/default.nix b/pkgs/test/haskell/setBuildTarget/default.nix
new file mode 100644
index 000000000000..b1335e2a74cf
--- /dev/null
+++ b/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"
+''
+
diff --git a/pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal b/pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal
new file mode 100644
index 000000000000..7395e139451c
--- /dev/null
+++ b/pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal
@@ -0,0 +1,16 @@
+cabal-version: >=1.10
+name: haskell-setBuildTarget
+version: 0.1.0.0
+author: Isaac Shapira
+maintainer: fresheyeball@protonmail.com
+build-type: Simple
+
+executable foo
+ main-is: Foo.hs
+ build-depends: base
+ default-language: Haskell2010
+
+executable bar
+ main-is: Bar.hs
+ build-depends: base
+ default-language: Haskell2010