diff options
author | Isaac Shapira <fresheyeball@protonmail.com> | 2021-04-23 13:55:38 -0600 |
---|---|---|
committer | (cdep)illabout <cdep.illabout@gmail.com> | 2021-05-02 13:35:07 +0900 |
commit | d725ac794286e3464d80f5bce69da98ff4b2ebbf (patch) | |
tree | 5e617d1c5230b3406acd98e5102046d3f60bd40e /pkgs/test | |
parent | 111151c4bc57287ef449eb4f06083d6aedccaa19 (diff) |
Add haskell.lib.setBuiltTarget, and support non library compiling of a single target
Diffstat (limited to 'pkgs/test')
-rw-r--r-- | pkgs/test/haskell/default.nix | 1 | ||||
-rw-r--r-- | pkgs/test/haskell/setBuildTarget/Bar.hs | 4 | ||||
-rw-r--r-- | pkgs/test/haskell/setBuildTarget/Foo.hs | 4 | ||||
-rw-r--r-- | pkgs/test/haskell/setBuildTarget/Setup.hs | 2 | ||||
-rw-r--r-- | pkgs/test/haskell/setBuildTarget/default.nix | 26 | ||||
-rw-r--r-- | pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal | 16 |
6 files changed, 53 insertions, 0 deletions
diff --git a/pkgs/test/haskell/default.nix b/pkgs/test/haskell/default.nix index 8171f929311b1..eb389f4051f87 100644 --- a/pkgs/test/haskell/default.nix +++ b/pkgs/test/haskell/default.nix @@ -3,4 +3,5 @@ lib.recurseIntoAttrs { shellFor = callPackage ./shellFor { }; documentationTarball = callPackage ./documentationTarball { }; + setBuildTarget = callPackage ./setBuildTarget { }; } diff --git a/pkgs/test/haskell/setBuildTarget/Bar.hs b/pkgs/test/haskell/setBuildTarget/Bar.hs new file mode 100644 index 0000000000000..010014082c7d0 --- /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 0000000000000..fec7bb11fe6c1 --- /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 0000000000000..9a994af677b0d --- /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 0000000000000..161cecd9ec37f --- /dev/null +++ b/pkgs/test/haskell/setBuildTarget/default.nix @@ -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" +'' + diff --git a/pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal b/pkgs/test/haskell/setBuildTarget/haskell-setBuildTarget.cabal new file mode 100644 index 0000000000000..7395e139451cc --- /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 |