cabal2nix 2.3.1 → 2.4
raw patch · 14 files changed
+131/−132 lines, 14 filesdep ~CabalPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: Cabal
API changes (from Hackage documentation)
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSONKey Distribution.Package.PackageName
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance (Control.DeepSeq.NFData v, Control.DeepSeq.NFData c, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Distribution.PackageDescription.CondTree v c a)
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.ModuleName.ModuleName
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Package.Dependency
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.Benchmark
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.BenchmarkInterface
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.BenchmarkType
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.BuildInfo
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.BuildType
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.ConfVar
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.Executable
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.Flag
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.FlagName
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.GenericPackageDescription
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.Library
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.ModuleReexport
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.ModuleRenaming
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.PackageDescription
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.RepoKind
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.RepoType
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.SetupBuildInfo
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.SourceRepo
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.TestSuite
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.TestSuiteInterface
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.PackageDescription.TestType
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Version.VersionRange
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Distribution.PackageDescription.Condition a)
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Package.Dependency
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Package.PackageIdentifier
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Package.PackageName
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Data.Version.Version
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Package.Dependency
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Package.PackageIdentifier
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Package.PackageName
+ Cabal2nix: cabal2nix' :: [String] -> IO (Either Doc Derivation)
+ Distribution.Nixpkgs.Haskell.Derivation: enableSeparateDataOutput :: Lens' Derivation Bool
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSONKey Distribution.Types.PackageName.PackageName
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance (Control.DeepSeq.NFData v, Control.DeepSeq.NFData c, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Distribution.Types.CondTree.CondBranch v c a)
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance (Control.DeepSeq.NFData v, Control.DeepSeq.NFData c, Control.DeepSeq.NFData a) => Control.DeepSeq.NFData (Distribution.Types.CondTree.CondTree v c a)
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.Benchmark.Benchmark
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.BenchmarkInterface.BenchmarkInterface
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.BenchmarkType.BenchmarkType
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.BuildInfo.BuildInfo
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.BuildType.BuildType
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.Executable.Executable
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ExecutableScope.ExecutableScope
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ForeignLib.ForeignLib
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ForeignLib.LibVersionInfo
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ForeignLibOption.ForeignLibOption
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ForeignLibType.ForeignLibType
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.GenericPackageDescription.ConfVar
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.GenericPackageDescription.Flag
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.GenericPackageDescription.FlagName
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.GenericPackageDescription.GenericPackageDescription
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.IncludeRenaming.IncludeRenaming
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.Library.Library
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.Mixin.Mixin
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ModuleReexport.ModuleReexport
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.ModuleRenaming.ModuleRenaming
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.PackageDescription.PackageDescription
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.SetupBuildInfo.SetupBuildInfo
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.SourceRepo.RepoKind
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.SourceRepo.RepoType
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.SourceRepo.SourceRepo
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.TestSuite.TestSuite
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.TestSuiteInterface.TestSuiteInterface
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData Distribution.Types.TestType.TestType
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Control.DeepSeq.NFData a => Control.DeepSeq.NFData (Distribution.Types.Condition.Condition a)
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Types.Dependency.Dependency
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Types.PackageId.PackageIdentifier
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Types.PackageName.PackageName
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Types.Dependency.Dependency
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Types.PackageId.PackageIdentifier
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.String.IsString Distribution.Version.Version
Files
- README.md +1/−1
- cabal2nix.cabal +6/−6
- hackage2nix/HackageGit.hs +3/−3
- hackage2nix/Main.hs +4/−3
- src/Cabal2nix.hs +15/−9
- src/Distribution/Nixpkgs/Haskell/Derivation.hs +6/−3
- src/Distribution/Nixpkgs/Haskell/FromCabal.hs +16/−25
- src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs +9/−5
- src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs +29/−27
- src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs +2/−2
- src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs +12/−10
- src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +7/−6
- src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs +15/−21
- src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs +6/−11
README.md view
@@ -49,7 +49,7 @@ This derivation will not fetch from hackage, but instead use the directory which contains the derivation as the source repository. -`cabal2nix` currently supports the following respository types:+`cabal2nix` currently supports the following repository types: * directory * source archive (zip, tar.gz, ...) from http or https URL or local file.
cabal2nix.cabal view
@@ -3,7 +3,7 @@ -- see: https://github.com/sol/hpack name: cabal2nix-version: 2.3.1+version: 2.4 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: .@@ -66,7 +66,7 @@ maintainer: Peter Simons <simons@cryp.to> license: BSD3 license-file: LICENSE-tested-with: GHC > 7.10 && < 8.1+tested-with: GHC > 7.10 && < 8.3 build-type: Custom cabal-version: >= 1.10 @@ -93,7 +93,7 @@ , ansi-wl-pprint , base < 5 , bytestring- , Cabal > 1.24+ , Cabal > 2 , containers , deepseq >= 1.4 , directory@@ -141,7 +141,7 @@ , ansi-wl-pprint , base < 5 , bytestring- , Cabal > 1.24+ , Cabal > 2 , containers , deepseq >= 1.4 , directory@@ -173,7 +173,7 @@ , ansi-wl-pprint , base < 5 , bytestring- , Cabal > 1.24+ , Cabal > 2 , containers , deepseq >= 1.4 , directory@@ -212,7 +212,7 @@ , ansi-wl-pprint , base < 5 , bytestring- , Cabal > 1.24+ , Cabal > 2 , containers , deepseq >= 1.4 , directory
hackage2nix/HackageGit.hs view
@@ -16,7 +16,7 @@ import Distribution.Nixpkgs.Haskell.OrphanInstances ( ) import Distribution.Package import Distribution.PackageDescription-import Distribution.PackageDescription.Parse ( parsePackageDescription, ParseResult(..) )+import Distribution.PackageDescription.Parse ( parseGenericPackageDescription, ParseResult(..) ) import Distribution.Text import Distribution.Version import OpenSSL.Digest ( digest, digestByName )@@ -31,7 +31,7 @@ discoverPackageVersions :: Hackage -> String -> IO Hackage discoverPackageVersions db pkg = do vs <- getSubDirs (path </> pkg)- return (Map.insert (PackageName pkg) (Set.fromList (Prelude.map fromString vs)) db)+ return (Map.insert (mkPackageName pkg) (Set.fromList (Prelude.map fromString vs)) db) getSubDirs :: FilePath -> IO [FilePath] getSubDirs path = do@@ -47,7 +47,7 @@ readPackage dirPrefix (PackageIdentifier name version) = do let cabalFile = dirPrefix </> unPackageName name </> display version </> unPackageName name <.> "cabal" buf <- BS.readFile cabalFile- cabal <- case parsePackageDescription (decodeUTF8 buf) of+ cabal <- case parseGenericPackageDescription (decodeUTF8 buf) of ParseOk _ a -> return a ParseFailed err -> fail (cabalFile ++ ": " ++ show err) return (cabal, printSHA256 (digest (digestByName "sha256") buf))
hackage2nix/Main.hs view
@@ -78,8 +78,9 @@ . Map.delete "som" -- TODO: https://github.com/NixOS/cabal2nix/issues/164 . Map.delete "type" -- TODO: https://github.com/NixOS/cabal2nix/issues/163 . Map.delete "control-invariants" -- TODO: depends on "assert"- . over (at ("hermes")) ((fmap (set (contains "1.3.4.3") False))) -- TODO: https://github.com/haskell/hackage-server/issues/436- . over (at ("gogol-admin-reports")) ((fmap (set (contains "0.2.0") False))) -- TODO: https://github.com/commercialhaskell/all-cabal-hashes/issues/11+ . over (at ("hermes")) ((fmap (set (contains "1.3.4.3") False))) -- TODO: https://github.com/haskell/hackage-server/issues/436+ . over (at ("gogol-admin-reports")) ((fmap (set (contains "0.2.0") False))) -- TODO: https://github.com/commercialhaskell/all-cabal-hashes/issues/11+ . over (at ("wai-middleware-prometheus")) ((fmap (set (contains "0.2.0") False))) -- TODO: https://github.com/commercialhaskell/all-cabal-hashes/issues/15 hackage <- fixup <$> readHackage hackageRepository let hackagePackagesFile :: FilePath@@ -200,4 +201,4 @@ | otherwise = Nothing mangle :: PackageIdentifier -> String-mangle (PackageIdentifier (PackageName name) v) = name ++ '_' : [ if c == '.' then '_' else c | c <- display v ]+mangle (PackageIdentifier name v) = unPackageName name ++ '_' : [ if c == '.' then '_' else c | c <- display v ]
src/Cabal2nix.hs view
@@ -2,7 +2,7 @@ {-# LANGUAGE OverloadedStrings #-} module Cabal2nix- ( main, cabal2nix+ ( main, cabal2nix, cabal2nix' ) where @@ -19,7 +19,7 @@ import Distribution.Nixpkgs.Haskell.FromCabal import Distribution.Nixpkgs.Haskell.PackageSourceSpec import Distribution.Nixpkgs.Meta-import Distribution.PackageDescription ( FlagName(..), FlagAssignment )+import Distribution.PackageDescription ( mkFlagName, FlagAssignment ) import Distribution.Simple.Utils ( lowercase ) import Distribution.System import Distribution.Text@@ -34,7 +34,7 @@ data Options = Options { optSha256 :: Maybe String , optMaintainer :: [String]---, optPlatform :: [String] -- TODO: fix command line handling of platforms+--, optPlatform :: [String] -- TODO: fix command line handling of platforms , optHaddock :: Bool , optDoCheck :: Bool , optJailbreak :: Bool@@ -108,7 +108,7 @@ , P2.fillSep (map P2.text (words ( "If the URI refers to a cabal file, information for building the package " ++ "will be retrieved from that file, but hackage will be used as a source " ++ "for the derivation. Otherwise, the supplied URI will be used to as the "- ++ "souce for the derivation and the information is taken from the cabal file "+ ++ "source for the derivation and the information is taken from the cabal file " ++ "at the root of the downloaded source." ))) ]))@@ -118,8 +118,8 @@ main = bracket (return ()) (\() -> hFlush stdout >> hFlush stderr) $ \() -> cabal2nix =<< getArgs -cabal2nix :: [String] -> IO ()-cabal2nix args = do+cabal2nix' :: [String] -> IO (Either Doc Derivation)+cabal2nix' args = do Options {..} <- handleParseResult $ execParserPure defaultPrefs pinfo args pkg <- getPackage optHackageDb $ Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)@@ -165,10 +165,16 @@ , text "" , text " if pkgs.lib.inNixShell then drv.env else drv" ]+ pure $ if optNixShellOutput then Left shell else Right deriv - print (if optNixShellOutput then shell else pPrint deriv)+cabal2nix :: [String] -> IO ()+cabal2nix args = do+ v <- cabal2nix' args+ print $ case v of+ Left shell -> shell+ Right d -> pPrint d readFlagList :: [String] -> FlagAssignment readFlagList = map tagWithValue- where tagWithValue ('-':fname) = (FlagName (lowercase fname), False)- tagWithValue fname = (FlagName (lowercase fname), True)+ where tagWithValue ('-':fname) = (mkFlagName (lowercase fname), False)+ tagWithValue fname = (mkFlagName (lowercase fname), True)
src/Distribution/Nixpkgs/Haskell/Derivation.hs view
@@ -8,7 +8,7 @@ , extraFunctionArgs, libraryDepends, executableDepends, testDepends, configureFlags , cabalFlags, runHaddock, jailbreak, doCheck, testTarget, hyperlinkSource, enableSplitObjs , enableLibraryProfiling, enableExecutableProfiling, phaseOverrides, editedCabalFile, metaSection- , dependencies, setupDepends, benchmarkDepends+ , dependencies, setupDepends, benchmarkDepends, enableSeparateDataOutput ) where @@ -23,7 +23,7 @@ import Distribution.Nixpkgs.Haskell.OrphanInstances ( ) import Distribution.Nixpkgs.Meta import Distribution.Package-import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )+import Distribution.PackageDescription ( FlagAssignment, unFlagName ) import GHC.Generics ( Generic ) import Language.Nix import Language.Nix.PrettyPrinting@@ -57,6 +57,7 @@ , _enableSplitObjs :: Bool , _phaseOverrides :: String , _editedCabalFile :: String+ , _enableSeparateDataOutput :: Bool , _metaSection :: Meta } deriving (Show, Eq, Generic)@@ -87,6 +88,7 @@ , _enableSplitObjs = error "undefined Derivation.enableSplitObjs" , _phaseOverrides = error "undefined Derivation.phaseOverrides" , _editedCabalFile = error "undefined Derivation.editedCabalFile"+ , _enableSeparateDataOutput = error "undefined Derivation.enableSeparateDataOutput" , _metaSection = error "undefined Derivation.metaSection" } @@ -112,6 +114,7 @@ , listattr "configureFlags" empty (map (show . show) renderedFlags) , boolattr "isLibrary" (not _isLibrary || _isExecutable) _isLibrary , boolattr "isExecutable" (not _isLibrary || _isExecutable) _isExecutable+ , boolattr "enableSeparateDataOutput" _enableSeparateDataOutput _enableSeparateDataOutput , onlyIf (_setupDepends /= mempty) $ pPrintBuildInfo "setup" _setupDepends , onlyIf (_libraryDepends /= mempty) $ pPrintBuildInfo "library" _libraryDepends , onlyIf (_executableDepends /= mempty) $ pPrintBuildInfo "executable" _executableDepends@@ -137,7 +140,7 @@ , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage] ] - renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text f | (FlagName f, enable) <- _cabalFlags ]+ renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text (unFlagName f) | (f, enable) <- _cabalFlags ] ++ map text (toAscList _configureFlags) isHackagePackage = "mirror://hackage/" `isPrefixOf` derivUrl _src sourceAttr (DerivationSource{..})
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -7,7 +7,6 @@ ) where -import Control.Arrow ( second ) import Control.Lens import Data.Maybe import Data.Set ( Set )@@ -24,7 +23,10 @@ import Distribution.Package import Distribution.PackageDescription import qualified Distribution.PackageDescription as Cabal-import Distribution.PackageDescription.Configuration+import Distribution.Types.LegacyExeDependency as Cabal+import Distribution.Types.PkgconfigDependency as Cabal+import Distribution.PackageDescription.Configuration as Cabal+import Distribution.Types.ComponentRequestedSpec as Cabal import Distribution.System import Distribution.Text ( display ) import Distribution.Version@@ -40,8 +42,14 @@ -- 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 (enableBenchmarks (enableTests genDesc))+ finalize resolver = finalizePD flags requestedComponents resolver arch compiler constraints genDesc + requestedComponents :: ComponentRequestedSpec+ requestedComponents = defaultComponentRequestedSpec+ { testsRequested = True+ , benchmarksRequested = True+ }+ descr :: PackageDescription; missingDeps :: [Dependency] (descr,missingDeps) = case finalize jailbrokenResolver of Left m -> case finalize (const True) of@@ -75,6 +83,7 @@ & enableSplitObjs .~ True & enableLibraryProfiling .~ False & enableExecutableProfiling .~ False+ & enableSeparateDataOutput .~ not (null dataFiles) & subpath .~ "." & phaseOverrides .~ mempty & editedCabalFile .~ (if xrev > 0@@ -93,7 +102,7 @@ xrev = maybe 0 read (lookup "x-revision" customFieldsPD) resolveInHackage :: Identifier -> Binding- resolveInHackage i | (i^.ident) `elem` [ n | (Dependency (PackageName n) _) <- missingDeps ] = bindNull i+ resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _) <- missingDeps ] = bindNull i | otherwise = binding # (i, path # ["self",i]) -- TODO: "self" shouldn't be hardcoded. goodScopes :: Set [Identifier]@@ -109,15 +118,15 @@ | otherwise = bindNull i resolveInHackageThenNixpkgs :: Identifier -> Binding- resolveInHackageThenNixpkgs i | haskellResolver (Dependency (PackageName (i^.ident)) anyVersion) = resolveInHackage i+ resolveInHackageThenNixpkgs i | haskellResolver (Dependency (mkPackageName (i^.ident)) anyVersion) = resolveInHackage i | otherwise = resolveInNixpkgs i convertBuildInfo :: Cabal.BuildInfo -> Nix.BuildInfo convertBuildInfo Cabal.BuildInfo {..} = mempty & haskell .~ Set.fromList [ resolveInHackage (toNixName x) | (Dependency x _) <- targetBuildDepends ] & system .~ Set.fromList [ resolveInNixpkgs y | x <- extraLibs, y <- libNixName x ]- & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | Dependency (PackageName x) _ <- pkgconfigDepends, y <- libNixName x ]- & tool .~ Set.fromList [ resolveInHackageThenNixpkgs y | Dependency (PackageName x) _ <- buildTools, y <- buildToolNixName x ]+ & pkgconfig .~ Set.fromList [ resolveInNixpkgs y | PkgconfigDependency x _ <- pkgconfigDepends, y <- libNixName (unPkgconfigName x) ]+ & tool .~ Set.fromList [ resolveInHackageThenNixpkgs y | LegacyExeDependency x _ <- buildTools, y <- buildToolNixName x ] convertSetupBuildInfo :: Cabal.SetupBuildInfo -> Nix.BuildInfo convertSetupBuildInfo bi = mempty@@ -125,21 +134,3 @@ 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 }--enableBenchmarks :: GenericPackageDescription -> GenericPackageDescription-enableBenchmarks gd = gd { condBenchmarks = flaggedBenchmarks }- where- flaggedBenchmarks :: [(String, CondTree ConfVar [Dependency] Benchmark)]- flaggedBenchmarks = map (second (mapTreeData enableBenchmark)) (condBenchmarks gd)-- enableBenchmark :: Benchmark -> Benchmark- enableBenchmark t = t { benchmarkEnabled = True }
src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs view
@@ -1,11 +1,15 @@+{-# LANGUAGE OverloadedStrings #-}+ module Distribution.Nixpkgs.Haskell.FromCabal.Flags ( configureCabalFlags ) where +import Distribution.Nixpkgs.Haskell.OrphanInstances ( )+ import Distribution.Package import Distribution.PackageDescription-import Data.Version+import Distribution.Version configureCabalFlags :: PackageIdentifier -> FlagAssignment-configureCabalFlags (PackageIdentifier (PackageName name) version)+configureCabalFlags (PackageIdentifier name version) | name == "accelerate-examples"= [disable "opencl"] | name == "arithmoi" = [disable "llvm"] | name == "darcs" = [enable "library", enable "force-char8-encoding"]@@ -34,7 +38,7 @@ | name == "haskeline" = [enable "terminfo"] | name == "haste-compiler" = [enable "portable"] | name == "highlighting-kate" = [enable "pcre-light"]- | name == "hlibsass" && version >= Version [0,1,5] []+ | name == "hlibsass" && version >= mkVersion [0,1,5] = [enable "externalLibsass"] | name == "hmatrix" = [enable "openblas"] | name == "hslua" = [enable "system-lua"]@@ -51,7 +55,7 @@ | otherwise = [] enable :: String -> (FlagName,Bool)-enable name = (FlagName name, True)+enable name = (mkFlagName name, True) disable :: String -> (FlagName,Bool)-disable name = (FlagName name, False)+disable name = (mkFlagName name, False)
src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs view
@@ -1,37 +1,39 @@+{-# LANGUAGE ViewPatterns #-}+ module Distribution.Nixpkgs.Haskell.FromCabal.License ( fromCabalLicense ) where import Distribution.Nixpkgs.License import Distribution.License ( License(..), knownLicenses ) import Distribution.Text (display) import Data.List (intercalate)-import Data.Version+import Distribution.Version -- TODO: Programatically strip trailing zeros from license version numbers. fromCabalLicense :: Distribution.License.License -> Distribution.Nixpkgs.License.License-fromCabalLicense (GPL Nothing) = Unknown (Just "GPL")-fromCabalLicense (GPL (Just (Version [2] []))) = Known "stdenv.lib.licenses.gpl2"-fromCabalLicense (GPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.gpl3"-fromCabalLicense (GPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.gpl3"-fromCabalLicense (LGPL Nothing) = Unknown (Just "LGPL")-fromCabalLicense (LGPL (Just (Version [2,1] []))) = Known "stdenv.lib.licenses.lgpl21"-fromCabalLicense (LGPL (Just (Version [2] []))) = Known "stdenv.lib.licenses.lgpl2"-fromCabalLicense (LGPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.lgpl3"-fromCabalLicense (LGPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.lgpl3"-fromCabalLicense (AGPL Nothing) = Unknown (Just "AGPL")-fromCabalLicense (AGPL (Just (Version [3] []))) = Known "stdenv.lib.licenses.agpl3"-fromCabalLicense (AGPL (Just (Version [3,0] []))) = Known "stdenv.lib.licenses.agpl3"-fromCabalLicense (MPL (Version [2,0] [])) = Known "stdenv.lib.licenses.mpl20"-fromCabalLicense BSD2 = Known "stdenv.lib.licenses.bsd2"-fromCabalLicense BSD3 = Known "stdenv.lib.licenses.bsd3"-fromCabalLicense BSD4 = Known "stdenv.lib.licenses.bsdOriginal"-fromCabalLicense MIT = Known "stdenv.lib.licenses.mit"-fromCabalLicense PublicDomain = Known "stdenv.lib.licenses.publicDomain"-fromCabalLicense UnspecifiedLicense = Known "stdenv.lib.licenses.unfree"-fromCabalLicense AllRightsReserved = Known "stdenv.lib.licenses.unfree"-fromCabalLicense (Apache Nothing) = Known "stdenv.lib.licenses.asl20"-fromCabalLicense (Apache (Just (Version [2,0] []))) = Known "stdenv.lib.licenses.asl20"-fromCabalLicense ISC = Known "stdenv.lib.licenses.isc"-fromCabalLicense OtherLicense = Unknown Nothing-fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"- ++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)+fromCabalLicense (GPL Nothing) = Unknown (Just "GPL")+fromCabalLicense (GPL (Just (versionNumbers -> [2]))) = Known "stdenv.lib.licenses.gpl2"+fromCabalLicense (GPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.gpl3"+fromCabalLicense (GPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.gpl3"+fromCabalLicense (LGPL Nothing) = Unknown (Just "LGPL")+fromCabalLicense (LGPL (Just (versionNumbers -> [2,1]))) = Known "stdenv.lib.licenses.lgpl21"+fromCabalLicense (LGPL (Just (versionNumbers -> [2]))) = Known "stdenv.lib.licenses.lgpl2"+fromCabalLicense (LGPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.lgpl3"+fromCabalLicense (LGPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.lgpl3"+fromCabalLicense (AGPL Nothing) = Unknown (Just "AGPL")+fromCabalLicense (AGPL (Just (versionNumbers -> [3]))) = Known "stdenv.lib.licenses.agpl3"+fromCabalLicense (AGPL (Just (versionNumbers -> [3,0]))) = Known "stdenv.lib.licenses.agpl3"+fromCabalLicense (MPL (versionNumbers -> [2,0])) = Known "stdenv.lib.licenses.mpl20"+fromCabalLicense BSD2 = Known "stdenv.lib.licenses.bsd2"+fromCabalLicense BSD3 = Known "stdenv.lib.licenses.bsd3"+fromCabalLicense BSD4 = Known "stdenv.lib.licenses.bsdOriginal"+fromCabalLicense MIT = Known "stdenv.lib.licenses.mit"+fromCabalLicense PublicDomain = Known "stdenv.lib.licenses.publicDomain"+fromCabalLicense UnspecifiedLicense = Known "stdenv.lib.licenses.unfree"+fromCabalLicense AllRightsReserved = Known "stdenv.lib.licenses.unfree"+fromCabalLicense (Apache Nothing) = Known "stdenv.lib.licenses.asl20"+fromCabalLicense (Apache (Just (versionNumbers -> [2,0]))) = Known "stdenv.lib.licenses.asl20"+fromCabalLicense ISC = Known "stdenv.lib.licenses.isc"+fromCabalLicense OtherLicense = Unknown Nothing+fromCabalLicense l = error $ "Distribution.Nixpkgs.Haskell.FromCabal.License.fromCabalLicense: unknown license"+ ++ show l ++"\nChoose one of: " ++ intercalate ", " (map display knownLicenses)
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs view
@@ -10,8 +10,8 @@ -- | Map Cabal names to Nix attribute names. toNixName :: PackageName -> Identifier-toNixName (PackageName "") = error "toNixName: invalid empty package name"-toNixName (PackageName n) = fromString n+toNixName "" = error "toNixName: invalid empty package name"+toNixName n = fromString (unPackageName n) -- | Map library names specified in Cabal files to Nix package identifiers. --
src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs view
@@ -1,3 +1,5 @@+{-# LANGUAGE OverloadedStrings #-}+ module Distribution.Nixpkgs.Haskell.FromCabal.Normalize ( normalize, normalizeCabalFlags ) where import Control.Lens@@ -8,7 +10,7 @@ import Distribution.Nixpkgs.Haskell import Distribution.Nixpkgs.Meta import Distribution.Package-import Distribution.PackageDescription ( FlagAssignment, FlagName(..) )+import Distribution.PackageDescription ( FlagAssignment, mkFlagName, unFlagName ) import Distribution.Simple.Utils ( lowercase ) import Language.Nix hiding ( quote ) @@ -20,12 +22,12 @@ & over benchmarkDepends (normalizeBuildInfo (packageName drv)) & over metaSection normalizeMeta & over cabalFlags normalizeCabalFlags- & jailbreak %~ (&& (packageName drv /= PackageName "jailbreak-cabal"))+ & jailbreak %~ (&& (packageName drv /= "jailbreak-cabal")) normalizeBuildInfo :: PackageName -> BuildInfo -> BuildInfo-normalizeBuildInfo (PackageName pname) bi = bi- & haskell %~ Set.filter (\b -> view localName b /= fromString pname)- & tool %~ Set.filter (\b -> view localName b /= fromString pname)+normalizeBuildInfo pname bi = bi+ & haskell %~ Set.filter (\b -> view localName b /= fromString (unPackageName pname))+ & tool %~ Set.filter (\b -> view localName b /= fromString (unPackageName pname)) normalizeMeta :: Meta -> Meta normalizeMeta meta = meta@@ -45,14 +47,14 @@ quote (c:cs) = c : quote cs quote [] = [] --- |When a flag is specified multiple times, the first occurrence--- counts. This is counter-intuitive, IMHO, but it's how cabal does it.--- Flag names are spelled in all lowercase.+-- | When a flag is specified multiple times, the first occurrence counts. This+-- is counter-intuitive, IMHO, but it's how cabal does it. Flag names are+-- spelled in all lowercase. ----- >>> normalizeCabalFlags [(FlagName "foo", True), (FlagName "FOO", True), (FlagName "Foo", False)]+-- >>> normalizeCabalFlags [(mkFlagName "foo", True), (mkFlagName "FOO", True), (mkFlagName "Foo", False)] -- [(FlagName "foo",True)] normalizeCabalFlags :: FlagAssignment -> FlagAssignment normalizeCabalFlags flags' = nubBy ((==) `on` fst) (sortBy (compare `on` fst) flags) where- flags = [ (FlagName (lowercase n), b) | (FlagName n, b) <- flags' ]+ flags = [ (mkFlagName (lowercase (unFlagName n)), b) | (n, b) <- flags' ]
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -27,7 +27,7 @@ collidesWithHaskellName b = view localName b `Set.member` buildDeps myName :: Identifier- myName = ident # n where PackageName n = packageName drv+ myName = ident # unPackageName (packageName drv) buildDeps :: Set Identifier buildDeps = Set.delete myName (setOf (dependencies . haskell . folded . localName) drv)@@ -89,6 +89,7 @@ , ("libconfig", over (libraryDepends . system) (replace "config = null" (pkg "libconfig"))) , ("liquid-fixpoint", set (executableDepends . system . contains (pkg "ocaml")) True . set (testDepends . system . contains (pkg "z3")) True) , ("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) , ("mwc-random", set doCheck False) , ("mysql", set (libraryDepends . system . contains (pkg "mysql")) True)@@ -104,7 +105,6 @@ , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"]))) , ("sdr", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64))) -- https://github.com/adamwalker/sdr/issues/2 , ("shake-language-c", set doCheck False) -- https://github.com/samplecount/shake-language-c/issues/26- , ("sharc-timbre", set (metaSection . broken) True) -- The build takes insanely long, i.e. >8 hours. , ("ssh", set doCheck False) -- test suite runs forever, probably can't deal with our lack of network access , ("stack", set phaseOverrides stackOverrides . set doCheck False) , ("stripe-http-streams", set doCheck False . set (metaSection . broken) False)@@ -225,8 +225,9 @@ xmonadPostInstall = unlines [ "postInstall = ''" , " shopt -s globstar"- , " mkdir -p $out/share/man/man1"- , " mv \"$out/\"**\"/man/\"*.1 $out/share/man/man1/"+ , " mkdir -p $doc/share/man/man1"+ , " mv \"$data/\"**\"/man/\"*[0-9] $doc/share/man/man1/"+ , " rm \"$data/\"**\"/man/\"*" , "'';" ] @@ -287,8 +288,8 @@ . over (libraryDepends . haskell) (Set.union (Set.fromList (map bind ["self.base", "self.cereal", "self.mtl", "self.text", "self.bytestring"]))) webkitgtk24xHook :: Derivation -> Derivation -- https://github.com/NixOS/cabal2nix/issues/145-webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x")) True- . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "webkitgtk24x"))+webkitgtk24xHook = set (libraryDepends . pkgconfig . contains (pkg "webkitgtk24x-gtk3")) True+ . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "webkitgtk24x-gtk3")) opencvOverrides :: Derivation -> Derivation opencvOverrides = set phaseOverrides "hardeningDisable = [ \"bindnow\" ];"
src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs view
@@ -1,7 +1,3 @@-{-# LANGUAGE CPP #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE DeriveGeneric #-}-{-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_GHC -fno-warn-orphans #-} module Distribution.Nixpkgs.Haskell.OrphanInstances ( ) where@@ -13,45 +9,47 @@ import Data.Yaml import Distribution.Compiler import Distribution.License-import Distribution.ModuleName hiding ( main, fromString ) import Distribution.Package import Distribution.PackageDescription import Distribution.System import Distribution.Text+import Distribution.Types.CondTree+import Distribution.Types.ExecutableScope+import Distribution.Types.ForeignLib+import Distribution.Types.ForeignLibOption+import Distribution.Types.ForeignLibType+import Distribution.Types.IncludeRenaming+import Distribution.Types.Mixin import Distribution.Version import Language.Haskell.Extension -#if !MIN_VERSION_Cabal(1,23,0)-import GHC.Generics ( Generic )-deriving instance Generic (CondTree v c a)-deriving instance Generic (Condition a)-deriving instance Generic ConfVar-deriving instance Generic Flag-deriving instance Generic GenericPackageDescription-#else instance NFData SetupBuildInfo-#endif- instance (NFData v, NFData c, NFData a) => NFData (CondTree v c a)+instance (NFData v, NFData c, NFData a) => NFData (CondBranch v c a) instance NFData Arch instance NFData Benchmark instance NFData BenchmarkInterface instance NFData BenchmarkType instance NFData BuildInfo instance NFData BuildType+instance NFData LibVersionInfo instance NFData CompilerFlavor instance NFData ConfVar-instance NFData Dependency+instance NFData ExecutableScope+instance NFData IncludeRenaming+instance NFData ForeignLibType+instance NFData ForeignLibOption instance NFData Executable instance NFData Extension instance NFData Flag+instance NFData Mixin instance NFData FlagName instance NFData GenericPackageDescription instance NFData KnownExtension instance NFData Language instance NFData Library+instance NFData ForeignLib instance NFData License-instance NFData ModuleName instance NFData ModuleReexport instance NFData ModuleRenaming instance NFData OS@@ -62,15 +60,11 @@ instance NFData TestSuite instance NFData TestSuiteInterface instance NFData TestType-instance NFData VersionRange instance NFData a => NFData (Condition a) instance NFData Platform instance NFData CompilerInfo instance NFData CompilerId instance NFData AbiTag--instance IsString PackageName where- fromString = text2isString "PackageName" instance IsString Version where fromString = text2isString "Version"
src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs view
@@ -9,7 +9,6 @@ import qualified Data.ByteString.Lazy.Char8 as LBS8 import Data.List ( isSuffixOf, isPrefixOf ) import Data.Maybe-import Data.Version import Distribution.Hackage.DB.Parsed import Distribution.Nixpkgs.Fetch import Distribution.Nixpkgs.Hashes@@ -17,7 +16,7 @@ import qualified Distribution.Package as Cabal import Distribution.PackageDescription import qualified Distribution.PackageDescription as Cabal-import Distribution.Text ( simpleParse )+import Distribution.Text ( simpleParse, display ) import OpenSSL.Digest ( digest, digestByName ) import System.Directory ( doesDirectoryExist, doesFileExist, createDirectoryIfMissing, getHomeDirectory, getDirectoryContents ) import System.Exit ( exitFailure )@@ -35,7 +34,6 @@ (derivSource, pkgDesc) <- fetchOrFromDB optHackageDB source flip Package pkgDesc <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource - fetchOrFromDB :: Maybe String -> Source -> IO (Maybe DerivationSource, Cabal.GenericPackageDescription) fetchOrFromDB optHackageDB src | "cabal://" `isPrefixOf` sourceUrl src = fmap ((,) Nothing) . fromDB optHackageDB . drop (length "cabal://") $ sourceUrl src@@ -54,15 +52,12 @@ Just r -> return r Nothing -> hPutStrLn stderr "*** no such package in the cabal database (did you run cabal update?). " >> exitFailure where+ pkgId :: Cabal.PackageIdentifier pkgId = fromMaybe (error ("invalid Haskell package id " ++ show pkg)) (simpleParse pkg)- Cabal.PackageName name = Cabal.pkgName pkgId- version = Cabal.pkgVersion pkgId+ name = Cabal.unPackageName (Cabal.packageName pkgId) lookupVersion :: DB.Map DB.Version Cabal.GenericPackageDescription -> Maybe Cabal.GenericPackageDescription- lookupVersion- | null (versionBranch version) = fmap snd . listToMaybe . reverse . DB.toAscList- | otherwise = DB.lookup version-+ lookupVersion = fmap snd . listToMaybe . reverse . DB.toAscList readFileMay :: String -> IO (Maybe String) readFileMay file = do@@ -117,9 +112,9 @@ exitFailure showPackageIdentifier :: Cabal.GenericPackageDescription -> String-showPackageIdentifier pkgDesc = name ++ "-" ++ showVersion version where+showPackageIdentifier pkgDesc = name ++ "-" ++ display version where pkgId = Cabal.package . Cabal.packageDescription $ pkgDesc- Cabal.PackageName name = Cabal.packageName pkgId+ name = Cabal.unPackageName (Cabal.packageName pkgId) version = Cabal.packageVersion pkgId cabalFromPath :: FilePath -> MaybeT IO (Bool, Cabal.GenericPackageDescription)