git.iko.soy/typeable/cabal2nix
on master help sign in
travis: switch CI builds from Stack to cabal-install

- Add license file. - Add Setup.lhs file. - Drop obsolete dependency on pretty-show.

commit1b9ba52ce78a5eba8bb68d12be5fa9c631e863c8 authorPeter Simons <simons@cryp.to> dateWed 15 Jun 2016, 16:45 (10 years ago) parentdb640d6
6 files changed+181−15
.travis.yml+75−11 LICENSE+30 Setup.lhs+40 cabal2nix.cabal+34−2 cabal2nix/Main.hs−1 package.yaml+2−1
.travis.yml+75−11
@@ -1,21 +1,85 @@
1−# .travis.yml
2−
3−language: haskell
1+# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
2+language: c
43sudo: false
54
65cache:
76 directories:
8− - $HOME/.stack
7+ - $HOME/.cabsnap
8+ - $HOME/.cabal/packages
9+
10+before_cache:
11+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
13+
14+matrix:
15+ include:
16+ - env: CABALVER=1.22 GHCVER=7.10.1
17+ compiler: ": #GHC 7.10.1"
18+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.1], sources: [hvr-ghc]}}
19+ - env: CABALVER=1.22 GHCVER=7.10.2
20+ compiler: ": #GHC 7.10.2"
21+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.2], sources: [hvr-ghc]}}
22+ - env: CABALVER=1.22 GHCVER=7.10.3
23+ compiler: ": #GHC 7.10.3"
24+ addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3], sources: [hvr-ghc]}}
25+ - env: CABALVER=1.24 GHCVER=8.0.1
26+ compiler: ": #GHC 8.0.1"
27+ addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1], sources: [hvr-ghc]}}
928
1029before_install:
11− - curl -L https://github.com/commercialhaskell/stack/releases/download/v1.1.2/stack-1.1.2-linux-x86_64.tar.gz | tar xfz -
12− - install -m 555 -D stack-1.1.2-linux-x86_64/stack $HOME/.local/bin/stack
13− - export PATH=$HOME/.local/bin:$PATH
14− - stack setup
30+ - unset CC
31+ - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
1532
1633install:
17− - stack build hscolour --copy-bins
18− - stack build --only-snapshot --flag=nix-paths:allow-relative-paths
34+ - cabal --version
35+ - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
36+ - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
37+ then
38+ zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
39+ $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
40+ fi
41+ - travis_retry cabal update -v
42+ - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
43+ - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
44+ - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
45+
46+# check whether current requested install-plan matches cached package-db snapshot
47+ - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
48+ then
49+ echo "cabal build-cache HIT";
50+ rm -rfv .ghc;
51+ cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
52+ cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
53+ else
54+ echo "cabal build-cache MISS";
55+ rm -rf $HOME/.cabsnap;
56+ mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
57+ cabal install --only-dependencies --enable-tests --enable-benchmarks;
58+ fi
1959
60+# snapshot package-db on cache miss
61+ - if [ ! -d $HOME/.cabsnap ];
62+ then
63+ echo "snapshotting package-db to build-cache";
64+ mkdir $HOME/.cabsnap;
65+ cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
66+ cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
67+ fi
68+
69+# Here starts the actual work to be performed for the package under test;
70+# any command which exits with a non-zero exit code causes the build to fail.
2071script:
21− - stack build --pedantic --test --haddock
72+ - if [ -f configure.ac ]; then autoreconf -i; fi
73+ - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
74+ - cabal build # this builds all libraries and executables (including tests/benchmarks)
75+ - cabal test
76+ - cabal check
77+ - cabal sdist # tests that a source-distribution can be generated
78+
79+# Check that the resulting source distribution can be built & installed.
80+# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
81+# `cabal install --force-reinstalls dist/*-*.tar.gz`
82+ - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
83+ (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
84+
85+# EOF
LICENSEnew file+30
@@ -0,0 +1,30 @@
1+Redistribution and use in source and binary forms, with or
2+without modification, are permitted provided that the
3+following conditions are met:
4+
5+ * Redistributions of source code must retain the above
6+ copyright notice, this list of conditions and the
7+ following disclaimer.
8+
9+ * Redistributions in binary form must reproduce the above
10+ copyright notice, this list of conditions and the
11+ following disclaimer in the documentation and/or other
12+ materials provided with the distribution.
13+
14+ * The names of its contributors may not be used to endorse
15+ or promote products derived from this software without
16+ specific prior written permission.
17+
18+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
19+CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
20+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
21+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
23+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
25+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
26+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29+OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Setup.lhsnew file+40
@@ -0,0 +1,40 @@
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+34−2
@@ -11,6 +11,8 @@ homepage: https://github.com/nixos/cabal2nix#readme
1111bug-reports: https://github.com/nixos/cabal2nix/issues
1212maintainer: Peter Simons <simons@cryp.to>
1313license: BSD3
14+license-file: LICENSE
15+tested-with: GHC > 7.10 && < 8.1
1416build-type: Simple
1517cabal-version: >= 1.10
1618
@@ -38,7 +40,6 @@ library
3840 , lens
3941 , optparse-applicative
4042 , pretty >= 1.1.2
41− , pretty-show
4243 , process
4344 , SHA
4445 , split
@@ -65,6 +66,38 @@ library
6566 Paths_cabal2nix
6667 default-language: Haskell2010
6768
69+executable cabal2nix
70+ main-is: Main.hs
71+ hs-source-dirs:
72+ cabal2nix
73+ ghc-options: -Wall
74+ build-depends:
75+ aeson
76+ , ansi-wl-pprint
77+ , base < 5
78+ , bytestring
79+ , Cabal > 1.24
80+ , containers
81+ , deepseq >= 1.4
82+ , directory
83+ , distribution-nixpkgs
84+ , filepath
85+ , hackage-db
86+ , language-nix
87+ , lens
88+ , optparse-applicative
89+ , pretty >= 1.1.2
90+ , process
91+ , SHA
92+ , split
93+ , text
94+ , transformers
95+ , yaml
96+ , cabal2nix
97+ other-modules:
98+ Paths_cabal2nix
99+ default-language: Haskell2010
100+
68101executable hackage2nix
69102 main-is: Main.hs
70103 hs-source-dirs:
@@ -86,7 +119,6 @@ executable hackage2nix
86119 , lens
87120 , optparse-applicative
88121 , pretty >= 1.1.2
89− , pretty-show
90122 , process
91123 , SHA
92124 , split
cabal2nix/Main.hs−1
@@ -153,7 +153,6 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> do
153153 , text " if pkgs.lib.inNixShell then drv.env else drv"
154154 ]
155155
156− -- putStrLn $ ppShow deriv
157156 print (if optNixShellOutput then shell else pPrint deriv)
158157
159158readFlagList :: [String] -> FlagAssignment
package.yaml+2−1
@@ -4,8 +4,10 @@ synopsis: Convert Cabal files into Nix build instructions.
44description: Convert Cabal files into Nix build instructions.
55maintainer: Peter Simons <simons@cryp.to>
66license: BSD3
7+license-file: LICENSE
78github: nixos/cabal2nix
89category: Distribution
10+tested-with: GHC > 7.10 && < 8.1
911
1012ghc-options: -Wall
1113
@@ -25,7 +27,6 @@ dependencies:
2527 - lens
2628 - optparse-applicative
2729 - pretty >= 1.1.2
28− - pretty-show
2930 - process
3031 - SHA
3132 - split