cabal2nix 2.10.0 → 2.10.1
raw patch · 7 files changed
+66/−15 lines, 7 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- README.md +5/−0
- cabal2nix.cabal +1/−1
- src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +52/−12
- test/Main.hs +5/−2
- test/golden-test-cases/nvim-hs.nix.golden +1/−0
- test/golden-test-cases/pinch.nix.golden +1/−0
- test/golden-test-cases/test-fixture.nix.golden +1/−0
README.md view
@@ -1,6 +1,11 @@ Cabal2nix ========= +[](http://hackage.haskell.org/package/cabal2nix)+[](http://stackage.org/lts/package/cabal2nix)+[](http://stackage.org/nightly/package/cabal2nix)+[](https://travis-ci.org/NixOS/cabal2nix)+ `cabal2nix` converts a single Cabal file into a single Nix build expression. For example:
cabal2nix.cabal view
@@ -1,5 +1,5 @@ name: cabal2nix-version: 2.10.0+version: 2.10.1 synopsis: Convert Cabal files into Nix build instructions. description: Convert Cabal files into Nix build instructions. Users of Nix can install the latest
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -1,12 +1,16 @@ {-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE ScopedTypeVariables #-} module Distribution.Nixpkgs.Haskell.FromCabal.PostProcess ( postProcess, pkg ) where import Control.Lens+import Control.Monad.Trans.State import Data.List.Split+import Data.Map ( Map )+import qualified Data.Map as Map+import Data.Map.Lens import Data.Set ( Set ) import qualified Data.Set as Set-import Data.Set.Lens import Distribution.Nixpkgs.Haskell import Distribution.Nixpkgs.Meta import Distribution.Package@@ -16,7 +20,11 @@ import Language.Nix postProcess :: Derivation -> Derivation-postProcess deriv = foldr ($) (fixGtkBuilds deriv) [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]+postProcess deriv =+ foldr (.) id [ f | (Dependency n vr, f) <- hooks, packageName deriv == n, packageVersion deriv `withinRange` vr ]+ . fixGtkBuilds+ . fixBuildDependsForTools+ $ deriv fixGtkBuilds :: Derivation -> Derivation fixGtkBuilds drv = drv & dependencies . pkgconfig %~ Set.filter (not . collidesWithHaskellName)@@ -24,26 +32,55 @@ & dependencies . tool %~ Set.filter (not . collidesWithHaskellName) where collidesWithHaskellName :: Binding -> Bool- collidesWithHaskellName b = view localName b `Set.member` buildDeps+ collidesWithHaskellName b = case buildDeps Map.!? view localName b of+ Nothing -> False -- totally uncollided+ Just p -> p /= view reference b -- identical is not collision, and important to preserve for cross myName :: Identifier myName = ident # unPackageName (packageName drv) - buildDeps :: Set Identifier- buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)+ buildDeps :: Map Identifier Path+ buildDeps = Map.delete myName (toMapOf (dependencies . haskell . to Set.toList . traverse . binding . ifolded) drv) +-- Per https://github.com/haskell/cabal/issues/5412 hvr considers+-- `build-depends` providing executables an accident, and fragile one at that,+-- unworthy of any compatibility hacks. But while he and the other Hackage+-- maintainers is dedicated to fixing executables and libraries on Hackage, test+-- suites and benchmarks are not a priority, as it is trivial to skip building+-- test-suites with cabal-install. Nix however wishes to build test suites much+-- more widely, so skipping those components is not an option.+--+-- Between that, and Stack not changing behavior as of+-- https://github.com/commercialhaskell/stack/pull/4132, it seems likely that+-- for a while packages scraped from Hackage will continue to improperly use+-- `build-depends: package-for-tool` instead of `build-tool-depends` (which does+-- also work for Stack). Until that changes, we provide do this to work around+-- those package's brokeness.+fixBuildDependsForTools :: Derivation -> Derivation+fixBuildDependsForTools = foldr (.) id+ [ fmap snd $ runState $ do+ needs <- use $ cloneLens c . haskell . contains p+ cloneLens c . tool . contains p ||= needs+ | (c :: ALens' Derivation BuildInfo) <- [ testDepends, benchmarkDepends ]+ , p <- self <$> [ "hspec-discover"+ , "tasty-discover"+ , "hsx2hs"+ , "markdown-unlit"+ ]+ ]+ hooks :: [(Dependency, Derivation -> Derivation)] hooks = [ ("Agda < 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agdaPostInstall) , ("Agda >= 2.5", set (executableDepends . tool . contains (pkg "emacs")) True . set phaseOverrides agda25PostInstall) , ("alex < 3.1.5", set (testDepends . tool . contains (pkg "perl")) True)- , ("alex", set (executableDepends . tool . contains (bind "self.happy")) True)+ , ("alex", set (executableDepends . tool . contains (self "happy")) True) , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True) , ("bindings-GLFW", over (libraryDepends . system) (Set.union (Set.fromList [bind "pkgs.xorg.libXext", bind "pkgs.xorg.libXfixes"]))) , ("bindings-lxc", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True) , ("Cabal", set doCheck False) -- test suite doesn't work in Nix- , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [bind "self.mtl", bind "self.parsec"]))) -- https://github.com/haskell/cabal/issues/5391+ , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391 , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17 , ("cabal-install", set doCheck False . set phaseOverrides cabalInstallPostInstall) , ("darcs", set phaseOverrides darcsInstallPostInstall . set doCheck False)@@ -88,14 +125,14 @@ , ("http-client-tls >= 0.2.2", set doCheck False) -- attempts to access the network , ("http-conduit", set doCheck False) -- attempts to access the network , ("imagemagick", set (libraryDepends . pkgconfig . contains (pkg "imagemagick")) True) -- https://github.com/NixOS/cabal2nix/issues/136- , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (bind "self.random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1+ , ("include-file <= 0.1.0.2", set (libraryDepends . haskell . contains (self "random")) True) -- https://github.com/Daniel-Diaz/include-file/issues/1 , ("js-jquery", set doCheck False) -- attempts to access the network , ("libconfig", over (libraryDepends . system) (replace "config = null" (pkg "libconfig"))) , ("libxml", set (configureFlags . contains "--extra-include-dir=${libxml2.dev}/include/libxml2") True) , ("liquid-fixpoint", set (executableDepends . system . contains (pkg "ocaml")) True . set (testDepends . system . contains (pkg "z3")) True . set (testDepends . system . contains (pkg "nettools")) True . set (testDepends . system . contains (pkg "git")) True . set doCheck False) , ("liquidhaskell", set (testDepends . system . contains (pkg "z3")) True)- , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (bind "self.only-buildable-on-windows")) False)- , ("MFlow < 4.6", set (libraryDepends . tool . contains (bind "self.cpphs")) True)+ , ("lzma-clib", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)) . set (libraryDepends . haskell . contains (self "only-buildable-on-windows")) False)+ , ("MFlow < 4.6", set (libraryDepends . tool . contains (self "cpphs")) True) , ("mwc-random", set doCheck False) , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True) , ("network-attoparsec", set doCheck False) -- test suite requires network access@@ -118,7 +155,7 @@ , ("target", set (testDepends . system . contains (pkg "z3")) True) , ("terminfo", set (libraryDepends . system . contains (pkg "ncurses")) True) , ("text", set doCheck False) -- break infinite recursion- , ("thyme", set (libraryDepends . tool . contains (bind "self.cpphs")) True) -- required on Darwin+ , ("thyme", set (libraryDepends . tool . contains (self "cpphs")) True) -- required on Darwin , ("twilio", set doCheck False) -- attempts to access the network , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";") , ("udev", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux))) , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)@@ -131,12 +168,15 @@ , ("wxcore", set (libraryDepends . pkgconfig . contains (pkg "wxGTK")) True) , ("X11", over (libraryDepends . system) (Set.union (Set.fromList $ map bind ["pkgs.xorg.libXinerama","pkgs.xorg.libXext","pkgs.xorg.libXrender","pkgs.xorg.libXScrnSaver"]))) , ("xmonad", set phaseOverrides xmonadPostInstall)- , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (bind "self.zip") (pkg "zip")))+ , ("zip-archive < 0.3.1", over (testDepends . tool) (replace (self "zip") (pkg "zip"))) , ("zip-archive >= 0.3.1 && < 0.3.2.3", over (testDepends . tool) (Set.union (Set.fromList [pkg "zip", pkg "unzip"]))) -- https://github.com/jgm/zip-archive/issues/35 ] pkg :: Identifier -> Binding pkg i = binding # (i, path # ["pkgs",i])++self :: Identifier -> Binding+self i = binding # (i, path # ["self",i]) pkgs :: [Identifier] -> Set Binding pkgs = Set.fromList . map pkg
test/Main.hs view
@@ -78,7 +78,10 @@ -- some temporary location that is empty. -- -- * Run this test with different kinds of encodings.-+--+-- * Run tests with a different target OS, like Darwin. The packages "iconv",+-- "crypt-sha512", "gl" might be worthwhile for testing since their output+-- differs on Darwin. testExecutable :: FilePath -> FilePath -> TestTree testExecutable exe cabalFile = do@@ -89,7 +92,7 @@ (\ref new -> ["diff", "-u", ref, new]) goldenFile nixFile- (callCommand (unwords ["env LANG=en_US.UTF-8", exe, "--sha256=deadbeef", "--compiler=ghc-8.2", "--", cabalFile, ">"++nixFile]))+ (callCommand (unwords ["env LANG=en_US.UTF-8", exe, "--sha256=deadbeef", "--system=x86_64-linux", "--compiler=ghc-8.2", "--", cabalFile, ">"++nixFile])) ------------------------------------------------------------------------------- -- * Helper functions
test/golden-test-cases/nvim-hs.nix.golden view
@@ -32,6 +32,7 @@ template-haskell text time time-locale-compat transformers transformers-base utf8-string ];+ testToolDepends = [ hspec-discover ]; homepage = "https://github.com/neovimhaskell/nvim-hs"; description = "Haskell plugin backend for neovim"; license = stdenv.lib.licenses.asl20;
test/golden-test-cases/pinch.nix.golden view
@@ -14,6 +14,7 @@ base bytestring containers hspec hspec-discover QuickCheck text unordered-containers vector ];+ testToolDepends = [ hspec-discover ]; homepage = "https://github.com/abhinav/pinch#readme"; description = "An alternative implementation of Thrift for Haskell"; license = stdenv.lib.licenses.bsd3;
test/golden-test-cases/test-fixture.nix.golden view
@@ -13,6 +13,7 @@ testHaskellDepends = [ base hspec hspec-discover mtl template-haskell transformers ];+ testToolDepends = [ hspec-discover ]; homepage = "http://github.com/cjdev/test-fixture#readme"; description = "Test monadic side-effects"; license = stdenv.lib.licenses.bsd3;