git.iko.soy/typeable/cabal2nix
on master help sign in
Use cabal-doctests to run the doctest suite.
1be933bPeter Simons
Setup.hsnew file+34
@@ -0,0 +1,34 @@
1+{-# LANGUAGE CPP #-}
2+{-# OPTIONS_GHC -Wall #-}
3+
4+module Main ( main ) where
5+
6+#ifndef MIN_VERSION_cabal_doctest
7+#define MIN_VERSION_cabal_doctest(x,y,z) 0
8+#endif
9+
10+#if MIN_VERSION_cabal_doctest(1,0,0)
11+
12+import Distribution.Extra.Doctest ( defaultMainWithDoctests )
13+main :: IO ()
14+main = defaultMainWithDoctests "doctests"
15+
16+#else
17+
18+#ifdef MIN_VERSION_Cabal
19+-- If the macro is defined, we have new cabal-install,
20+-- but for some reason we don't have cabal-doctest in package-db
21+--
22+-- Probably we are running cabal sdist, when otherwise using new-build
23+-- workflow
24+#warning You are configuring this package without cabal-doctest installed. \
25+ The doctests test-suite will not work as a result. \
26+ To fix this, install cabal-doctest before configuring.
27+#endif
28+
29+import Distribution.Simple
30+
31+main :: IO ()
32+main = defaultMain
33+
34+#endif
Setup.lhsdeleted−40
@@ -1,40 +0,0 @@
1−#! /usr/bin/env runhaskell
2−
3−> module Main ( main ) where
4−>
5−> import Data.Char
6−> import Data.Maybe
7−> import Distribution.PackageDescription
8−> import Distribution.Simple
9−> import Distribution.Simple.LocalBuildInfo
10−> import Distribution.Simple.Program
11−> import Distribution.Simple.Setup
12−>
13−> main :: IO ()
14−> main = defaultMainWithHooks simpleUserHooks
15−> { hookedPrograms = map simpleProgram programs
16−> , confHook = configure
17−> }
18−>
19−> programs :: [String]
20−> programs = ["nix-instantiate", "nix-build", "nix-env", "nix-store"]
21−>
22−> configure :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo
23−> configure (gpd, hbi) flags = do
24−> lbi' <- confHook simpleUserHooks (gpd, hbi) flags
25−> let paths = map (\p -> (p, maybe p programPath (lookupProgram (simpleProgram p) (withPrograms lbi)))) programs
26−> descr = localPkgDescr lbi'
27−> lib = fromJust (library descr)
28−> libbi = libBuildInfo lib
29−> lbi = lbi' { localPkgDescr = descr
30−> { library = Just (lib { libBuildInfo = libbi { cppOptions = cppOptions libbi ++ map fmtCppArg paths } })
31−> }
32−> }
33−> return lbi
34−>
35−> fmtCppArg :: (String, FilePath) -> String
36−> fmtCppArg (prg, path) = "-DPATH_TO_" ++ map mangle prg ++ "=" ++ show path
37−> where
38−> mangle :: Char -> Char
39−> mangle '-' = '_'
40−> mangle c = toUpper c
cabal2nix.cabal+9−3
@@ -1,9 +1,9 @@
1−-- This file has been generated from package.yaml by hpack version 0.17.0.
1+-- This file has been generated from package.yaml by hpack version 0.18.1.
2--
2--
3-- see: https://github.com/sol/hpack
3-- see: https://github.com/sol/hpack
4
4
5name: cabal2nix
5name: cabal2nix
6−version: 2.3
6+version: 2.3.1
7synopsis: Convert Cabal files into Nix build instructions.
7synopsis: Convert Cabal files into Nix build instructions.
8description: Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running:
8description: Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running:
9 .
9 .
@@ -67,7 +67,7 @@ maintainer: Peter Simons <simons@cryp.to>
67license: BSD3
67license: BSD3
68license-file: LICENSE
68license-file: LICENSE
69tested-with: GHC > 7.10 && < 8.1
69tested-with: GHC > 7.10 && < 8.1
70−build-type: Simple
70+build-type: Custom
71cabal-version: >= 1.10
71cabal-version: >= 1.10
72
72
73extra-source-files:
73extra-source-files:
@@ -77,6 +77,12 @@ source-repository head
77 type: git
77 type: git
78 location: https://github.com/nixos/cabal2nix
78 location: https://github.com/nixos/cabal2nix
79
79
80+custom-setup
81+ setup-depends:
82+ base >= 4 && <5
83+ , Cabal
84+ , cabal-doctest >= 1 && <1.1
85+
80library
86library
81 hs-source-dirs:
87 hs-source-dirs:
82 src
88 src
package.yaml+7−1
@@ -1,5 +1,5 @@
1name: cabal2nix
1name: cabal2nix
2−version: "2.3"
2+version: "2.3.1"
3synopsis: Convert Cabal files into Nix build instructions.
3synopsis: Convert Cabal files into Nix build instructions.
4author:
4author:
5 - Peter Simons
5 - Peter Simons
@@ -68,6 +68,12 @@ description: >
68
68
69 > nix-env -i cabal2nix
69 > nix-env -i cabal2nix
70
70
71+custom-setup:
72+ dependencies:
73+ - base >= 4 && <5
74+ - Cabal
75+ - cabal-doctest >= 1 && <1.1
76+
71ghc-options: -Wall
77ghc-options: -Wall
72
78
73extra-source-files:
79extra-source-files:
test/doctests.hs+7−3
@@ -1,6 +1,10 @@
1−module Main ( main ) where
1+module Main where
2
2
3+import Build_doctests (flags, pkgs, module_sources)
4+import Data.Foldable (traverse_)
3−import Test.DocTest
5+import Test.DocTest (doctest)
4
6
5main :: IO ()
7main :: IO ()
8+main = do let args = flags ++ pkgs ++ module_sources
9+ traverse_ putStrLn args -- optionally print arguments
6−main = doctest ["src"]
10+ doctest args