cabal2nix 2.0.2 → 2.0.3
raw patch · 3 files changed
+37/−39 lines, 3 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Distribution.Nixpkgs.Haskell.FromCabal: fromPackageDescription :: HaskellResolver -> NixpkgsResolver -> Bool -> [Dependency] -> FlagAssignment -> PackageDescription -> Derivation
+ Distribution.Nixpkgs.Haskell.FromCabal: fromPackageDescription :: HaskellResolver -> NixpkgsResolver -> [Dependency] -> FlagAssignment -> PackageDescription -> Derivation
Files
- cabal2nix.cabal +1/−1
- src/Distribution/Nixpkgs/Haskell/FromCabal.hs +28/−34
- src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +8/−4
cabal2nix.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: cabal2nix-version: 2.0.2+version: 2.0.3 synopsis: Convert Cabal files into Nix build instructions. description: Convert Cabal files into Nix build instructions. Users of Nix can install the latest version by running: .
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -34,41 +34,26 @@ type NixpkgsResolver = Identifier -> Maybe Binding fromGenericPackageDescription :: HaskellResolver -> NixpkgsResolver -> Platform -> CompilerInfo -> FlagAssignment -> [Constraint] -> GenericPackageDescription -> Derivation-fromGenericPackageDescription haskellResolver nixpkgsResolver arch compiler flags constraints descr'' =- -- TODO: This logic needs simplification and cleanup. :-(- case finalize haskellResolver of- Left _ -> case finalize jailbrokenResolver of- Left missing -> case finalize (const True) of- Left missing' -> error $ "finalizePackageDescription complains about missing dependencies \- \even though we told it that everything exists: " ++ show missing'- Right (descr_,_) -> fromPackageDescription haskellResolver nixpkgsResolver True missing flags descr_- Right _ -> fromPackageDescription haskellResolver nixpkgsResolver True [] flags descr- Right _ -> fromPackageDescription haskellResolver nixpkgsResolver False [] flags descr- where- descr :: PackageDescription- Right (descr,_) = finalize jailbrokenResolver-- -- We have to call the Cabal finalizer several times with different resolver functions, and this- -- convenience function makes our code shorter.- finalize :: HaskellResolver -> Either [Dependency] (PackageDescription,FlagAssignment)- finalize resolver = finalizePackageDescription flags resolver arch compiler constraints descr'-- jailbrokenResolver :: HaskellResolver- jailbrokenResolver (Dependency pkg _) = haskellResolver (Dependency pkg anyVersion)-- -- A variant of the cabal file that has all test suites enabled to ensure- -- that their dependencies are recognized by finalizePackageDescription.- descr' :: GenericPackageDescription- descr' = descr'' { condTestSuites = flaggedTests }+fromGenericPackageDescription haskellResolver nixpkgsResolver arch compiler flags constraints genDesc =+ fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags descr+ where+ -- We have to call the Cabal finalizer several times with different resolver+ -- functions, and this convenience function makes our code shorter.+ finalize :: HaskellResolver -> Either [Dependency] (PackageDescription,FlagAssignment)+ finalize resolver = finalizePackageDescription flags resolver arch compiler constraints (enableTests genDesc) - flaggedTests :: [(String, CondTree ConfVar [Dependency] TestSuite)]- flaggedTests = map (second (mapTreeData enableTest)) (condTestSuites descr'')+ descr :: PackageDescription; missingDeps :: [Dependency]+ (descr,missingDeps) = case finalize jailbrokenResolver of+ Left m -> case finalize (const True) of+ Left _ -> error ("Cabal cannot finalize " ++ display (packageId genDesc))+ Right (d,_) -> (d,m)+ Right (d,_) -> (d,[]) - enableTest :: TestSuite -> TestSuite- enableTest t = t { testEnabled = True }+ jailbrokenResolver :: HaskellResolver+ jailbrokenResolver (Dependency pkg _) = haskellResolver (Dependency pkg anyVersion) -fromPackageDescription :: HaskellResolver -> NixpkgsResolver -> Bool -> [Dependency] -> FlagAssignment -> PackageDescription -> Derivation-fromPackageDescription haskellResolver nixpkgsResolver mismatchedDeps missingDeps flags (PackageDescription {..}) = normalize $ postProcess $ nullDerivation+fromPackageDescription :: HaskellResolver -> NixpkgsResolver -> [Dependency] -> FlagAssignment -> PackageDescription -> Derivation+fromPackageDescription haskellResolver nixpkgsResolver missingDeps flags (PackageDescription {..}) = normalize $ postProcess $ nullDerivation & isLibrary .~ isJust library & pkgid .~ package & revision .~ xrev@@ -82,7 +67,7 @@ & configureFlags .~ mempty & cabalFlags .~ flags & runHaddock .~ maybe True (not . null . exposedModules) library- & jailbreak .~ (mismatchedDeps || not (null missingDeps))+ & jailbreak .~ False & doCheck .~ True & testTarget .~ mempty & hyperlinkSource .~ True@@ -110,7 +95,7 @@ | otherwise = binding # (i, path # ["self",i]) -- TODO: "self" shouldn't be hardcoded. goodScopes :: Set [Identifier]- goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome2"], ["gnome3"], ["kde4"]])+ goodScopes = Set.fromList (map ("pkgs":) [[], ["xorg"], ["xlibs"], ["gnome2"], ["gnome"], ["gnome3"], ["kde4"]]) resolveInNixpkgs :: Identifier -> Binding resolveInNixpkgs i@@ -137,3 +122,12 @@ bindNull :: Identifier -> Binding bindNull i = binding # (i, path # ["null"])++enableTests :: GenericPackageDescription -> GenericPackageDescription+enableTests gd = gd { condTestSuites = flaggedTests }+ where+ flaggedTests :: [(String, CondTree ConfVar [Dependency] TestSuite)]+ flaggedTests = map (second (mapTreeData enableTest)) (condTestSuites gd)++ enableTest :: TestSuite -> TestSuite+ enableTest t = t { testEnabled = True }
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -43,7 +43,7 @@ , ("bustle", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True) , ("Cabal", set doCheck False) -- test suite doesn't work in Nix , ("cabal-helper", set doCheck False) -- https://github.com/DanielG/cabal-helper/issues/17- , ("cabal-install", set phaseOverrides cabalInstallPostInstall)+ , ("cabal-install", set doCheck False . set phaseOverrides cabalInstallPostInstall) , ("darcs", set phaseOverrides darcsInstallPostInstall . set doCheck False) , ("dbus", set doCheck False) -- don't execute tests that try to access the network , ("dns", set testTarget "spec") -- don't execute tests that try to access the network@@ -62,7 +62,7 @@ , ("gi-gstvideo", gstLibAudioOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gi-gtk", giGtkPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gi-javascriptcore", giJavascriptCorePhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36- , ("gi-pango", giPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36+ , ("gi-pango", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gi-webkit2", giWebkit2PhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True) , ("git", set doCheck False) -- https://github.com/vincenthz/hit/issues/33@@ -73,12 +73,13 @@ , ("gtk3", gtk3Hook) , ("haddock", haddockHook) -- https://github.com/haskell/haddock/issues/511 , ("hakyll", set (testDepends . tool . contains (pkg "utillinux")) True) -- test suite depends on "rev"- , ("haskell-src-exts == 1.17.1", set doCheck False) -- test suite fails with ghc 8.0.1+ , ("haskell-src-exts", set doCheck False) , ("HFuse", set phaseOverrides hfusePreConfigure) , ("hfsevents", hfseventsOverrides) , ("hlibgit2 >= 0.18.0.14", set (testDepends . tool . contains (pkg "git")) True) , ("hmatrix", set phaseOverrides "preConfigure = \"sed -i hmatrix.cabal -e 's@/usr/@/dont/hardcode/paths/@'\";") , ("holy-project", set doCheck False) -- attempts to access the network+ , ("hoogle", set testTarget "--test-option=--no-net") , ("hsignal < 0.2.7.4", set phaseOverrides "prePatch = \"rm -v Setup.lhs\";") -- https://github.com/amcphail/hsignal/issues/1 , ("hslua", over (libraryDepends . each) (replace (pkg "lua") (pkg "lua5_1"))) , ("http-client", set doCheck False) -- attempts to access the network@@ -100,6 +101,7 @@ , ("pandoc", set jailbreak False) -- jailbreak-cabal break the build , ("pandoc >= 1.16.0.2", set doCheck False) -- https://github.com/jgm/pandoc/issues/2709 and https://github.com/fpco/stackage/issues/1332 , ("pandoc-citeproc", set doCheck False) -- https://github.com/jgm/pandoc-citeproc/issues/172+ , ("opencv", set phaseOverrides "hardeningDisable = [ \"bindnow\" ];") , ("qtah-cpp-qt5", set (libraryDepends . system . contains (bind "pkgs.qt5.qtbase")) True) , ("qtah-qt5", set (libraryDepends . tool . contains (bind "pkgs.qt5.qtbase")) True) , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))@@ -299,7 +301,9 @@ . set (libraryDepends . pkgconfig . contains (pkg "webkitgtk")) True giCairoPhaseOverrides :: Derivation -> Derivation-giCairoPhaseOverrides = over phaseOverrides (++'\n':txt) . giPhaseOverrides+giCairoPhaseOverrides = over phaseOverrides (++'\n':txt)+ . set (libraryDepends . pkgconfig . contains (pkg "cairo")) True+ . giPhaseOverrides where txt = unlines [ "preCompileBuildDriver = ''" , " PKG_CONFIG_PATH+=\":${cairo}/lib/pkgconfig\""