cabal2nix 2.0.4 → 2.1
raw patch · 10 files changed
+99/−42 lines, 10 filesdep +doctestPVP ok
version bump matches the API change (PVP)
Dependencies added: doctest
API changes (from Hackage documentation)
- Distribution.Nixpkgs.Fetch: instance Data.Aeson.Types.Class.FromJSON Distribution.Nixpkgs.Fetch.DerivationSource
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.Class.FromJSON Distribution.Nixpkgs.Haskell.FromCabal.Configuration.Configuration
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.Class.FromJSON Language.Nix.Identifier.Identifier
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.Class.FromJSON v => Data.Aeson.Types.Class.FromJSON (Data.Map.Base.Map Distribution.Package.PackageName v)
- Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.Class.FromJSON v => Data.Aeson.Types.Class.FromJSON (Data.Map.Base.Map Language.Nix.Identifier.Identifier v)
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.Class.FromJSON Distribution.Compiler.CompilerInfo
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.Class.FromJSON Distribution.Package.Dependency
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.Class.FromJSON Distribution.Package.PackageIdentifier
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.Class.FromJSON Distribution.Package.PackageName
- Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.Class.FromJSON Distribution.System.Platform
+ Distribution.Nixpkgs.Fetch: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Nixpkgs.Fetch.DerivationSource
+ Distribution.Nixpkgs.Haskell.Derivation: benchmarkDepends :: Lens' Derivation BuildInfo
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Nixpkgs.Haskell.FromCabal.Configuration.Configuration
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSON Language.Nix.Identifier.Identifier
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSONKey Distribution.Package.PackageName
+ Distribution.Nixpkgs.Haskell.FromCabal.Configuration: instance Data.Aeson.Types.FromJSON.FromJSONKey Language.Nix.Identifier.Identifier
+ Distribution.Nixpkgs.Haskell.OrphanInstances: instance Data.Aeson.Types.FromJSON.FromJSON Distribution.Compiler.CompilerInfo
+ 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.Aeson.Types.FromJSON.FromJSON Distribution.System.Platform
Files
- cabal2nix.cabal +33/−2
- hackage2nix/Main.hs +2/−1
- src/Distribution/Nixpkgs/Fetch.hs +1/−2
- src/Distribution/Nixpkgs/Haskell/Derivation.hs +5/−2
- src/Distribution/Nixpkgs/Haskell/FromCabal.hs +1/−0
- src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs +4/−0
- src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs +29/−34
- src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs +1/−0
- src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs +17/−1
- test/Main.hs +6/−0
cabal2nix.cabal view
@@ -1,9 +1,9 @@--- This file has been generated from package.yaml by hpack version 0.14.1.+-- This file has been generated from package.yaml by hpack version 0.17.0. -- -- see: https://github.com/sol/hpack name: cabal2nix-version: 2.0.4+version: 2.1 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: .@@ -179,4 +179,35 @@ other-modules: Paths_cabal2nix HackageGit+ default-language: Haskell2010++test-suite spec+ type: exitcode-stdio-1.0+ main-is: Main.hs+ hs-source-dirs:+ test+ ghc-options: -Wall+ build-depends:+ aeson+ , ansi-wl-pprint+ , base < 5+ , bytestring+ , Cabal > 1.24+ , containers+ , deepseq >= 1.4+ , directory+ , distribution-nixpkgs+ , filepath+ , hackage-db+ , language-nix+ , lens+ , optparse-applicative+ , pretty >= 1.1.2+ , process+ , SHA+ , split+ , text+ , transformers+ , yaml+ , doctest default-language: Haskell2010
hackage2nix/Main.hs view
@@ -78,7 +78,8 @@ . 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"- . Map.delete "hermes" -- TODO: https://github.com/haskell/hackage-server/issues/436+ . 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 hackage <- fixup <$> readHackage hackageRepository let hackagePackagesFile :: FilePath
src/Distribution/Nixpkgs/Fetch.hs view
@@ -79,8 +79,7 @@ fetch f = runMaybeT . fetchers where fetchers :: Source -> MaybeT IO (DerivationSource, a) fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)- [ (False, "zip", [])- , (False, "url", [])+ [ (False, "url", []) , (True, "git", ["--fetch-submodules"]) , (True, "hg", []) , (True, "svn", [])
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+ , dependencies, setupDepends, benchmarkDepends ) where @@ -43,6 +43,7 @@ , _libraryDepends :: BuildInfo , _executableDepends :: BuildInfo , _testDepends :: BuildInfo+ , _benchmarkDepends :: BuildInfo , _configureFlags :: Set String , _cabalFlags :: FlagAssignment , _runHaddock :: Bool@@ -71,6 +72,7 @@ , _libraryDepends = error "undefined Derivation.libraryDepends" , _executableDepends = error "undefined Derivation.executableDepends" , _testDepends = error "undefined Derivation.testDepends"+ , _benchmarkDepends = error "undefined Derivation.benchmarkDepends" , _configureFlags = error "undefined Derivation.configureFlags" , _cabalFlags = error "undefined Derivation.cabalFlags" , _runHaddock = error "undefined Derivation.runHaddock"@@ -88,7 +90,7 @@ makeLenses ''Derivation -makeLensesFor [("_setupDepends", "dependencies"), ("_libraryDepends", "dependencies"), ("_executableDepends", "dependencies"), ("_testDepends", "dependencies")] ''Derivation+makeLensesFor [("_setupDepends", "dependencies"), ("_libraryDepends", "dependencies"), ("_executableDepends", "dependencies"), ("_testDepends", "dependencies"), ("_benchmarkDepends", "dependencies")] ''Derivation instance Package Derivation where packageId = view pkgid@@ -111,6 +113,7 @@ , onlyIf (_libraryDepends /= mempty) $ pPrintBuildInfo "library" _libraryDepends , onlyIf (_executableDepends /= mempty) $ pPrintBuildInfo "executable" _executableDepends , onlyIf (_testDepends /= mempty) $ pPrintBuildInfo "test" _testDepends+ , onlyIf (_benchmarkDepends /= mempty) $ pPrintBuildInfo "benchmark" _benchmarkDepends , boolattr "enableLibraryProfiling" _enableLibraryProfiling _enableLibraryProfiling , boolattr "enableExecutableProfiling" _enableExecutableProfiling _enableExecutableProfiling , boolattr "enableSplitObjs" (not _enableSplitObjs) _enableSplitObjs
src/Distribution/Nixpkgs/Haskell/FromCabal.hs view
@@ -63,6 +63,7 @@ & libraryDepends .~ maybe mempty (convertBuildInfo . libBuildInfo) library & executableDepends .~ mconcat (map (convertBuildInfo . buildInfo) executables) & testDepends .~ mconcat (map (convertBuildInfo . testBuildInfo) testSuites)+ & benchmarkDepends .~ mconcat (map (convertBuildInfo . benchmarkBuildInfo) benchmarks) & Nix.setupDepends .~ maybe mempty convertSetupBuildInfo setupBuildInfo & configureFlags .~ mempty & cabalFlags .~ flags
src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs view
@@ -4,14 +4,18 @@ import Distribution.License ( License(..) ) import Data.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"
src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs view
@@ -2,8 +2,10 @@ module Distribution.Nixpkgs.Haskell.FromCabal.Name ( toNixName, libNixName, buildToolNixName ) where +import Data.Maybe import Data.String import Distribution.Package+import Distribution.Text import Language.Nix -- | Map Cabal names to Nix attribute names.@@ -11,20 +13,21 @@ toNixName (PackageName "") = error "toNixName: invalid empty package name" toNixName (PackageName n) = fromString n --- | Map libraries to Nix packages.+-- | Map library names specified in Cabal files to Nix package identifiers. -- -- TODO: This list should not be hard-coded here; it belongs into the Nixpkgs--- repository.+-- repository.+--+-- TODO: Re-use hook matching system from PostProcess.hs here. libNixName :: String -> [Identifier] libNixName "" = [] libNixName "adns" = return "adns" libNixName "alsa" = return "alsaLib" libNixName "alut" = return "freealut"-libNixName "appindicator-0.1" = return "appindicator"-libNixName "appindicator3-0.1" = return "appindicator"+libNixName "appindicator-0.1" = return "libappindicator-gtk2"+libNixName "appindicator3-0.1" = return "libappindicator-gtk3" libNixName "asound" = return "alsaLib"-libNixName "awesomium-1.6.5" = return "awesomium" libNixName "b2" = return "libb2" libNixName "bz2" = return "bzip2" libNixName "c++" = [] -- What is that?@@ -32,9 +35,6 @@ libNixName "cairo-pdf" = return "cairo" libNixName "cairo-ps" = return "cairo" libNixName "cairo-svg" = return "cairo"-libNixName "CEGUIBase-0.7.7" = return "CEGUIBase"-libNixName "CEGUIOgreRenderer-0.7.7" = return "CEGUIOgreRenderer"-libNixName "clutter-1.0" = return "clutter" libNixName "crypt" = [] -- provided by glibc libNixName "crypto" = return "openssl" libNixName "curses" = return "ncurses"@@ -49,18 +49,14 @@ libNixName "gdk-x11-2.0" = return "gdk_x11" libNixName "gio-2.0" = return "glib" libNixName "GL" = return "mesa"-libNixName "glib-2.0" = return "glib" libNixName "GLU" = ["freeglut","mesa"] libNixName "glut" = ["freeglut","mesa"]-libNixName "gmime-2.4" = return "gmime" libNixName "gnome-keyring" = return "gnome_keyring" libNixName "gnome-keyring-1" = return "gnome_keyring" libNixName "gnome-vfs-2.0" = return "gnome_vfs" libNixName "gnome-vfs-module-2.0" = return "gnome_vfs_module" libNixName "gobject-2.0" = return "glib" libNixName "gobject-introspection-1.0" = return "gobjectIntrospection"-libNixName "gstreamer-0.10" = return "gstreamer"-libNixName "gstreamer-1.0" = return "gstreamer" libNixName "gstreamer-audio-0.10" = return "gst_plugins_base" libNixName "gstreamer-audio-1.0" = return "gst_plugins_base" libNixName "gstreamer-base-0.10" = return "gst_plugins_base"@@ -74,9 +70,6 @@ libNixName "gtk+-2.0" = return "gtk2" libNixName "gtk+-3.0" = return "gtk3" libNixName "gtk-x11-2.0" = return "gtk_x11"-libNixName "gtkglext-1.0" = return "gtkglext"-libNixName "gtksourceview-2.0" = return "gtksourceview"-libNixName "gtksourceview-3.0" = return "gtksourceview" libNixName "hidapi-libusb" = return "hidapi" libNixName "icudata" = return "icu" libNixName "icui18n" = return "icu"@@ -87,34 +80,22 @@ libNixName "Imlib2" = return "imlib2" libNixName "iw" = return "wirelesstools" libNixName "jack" = return "libjack2"-libNixName "javascriptcoregtk-3.0" = return "javascriptcoregtk"-libNixName "javascriptcoregtk-4.0" = return "javascriptcoregtk" libNixName "jpeg" = return "libjpeg" libNixName "jvm" = return "jdk" libNixName "lapack" = return "liblapack" libNixName "ldap" = return "openldap"-libNixName "llvm-3.0" = return "llvm"-libNixName "llvm-3.5" = return "llvm"-libNixName "llvm-3.6" = return "llvm"-libNixName "llvm-3.7" = return "llvm"-libNixName "llvm-3.8" = return "llvm" libNixName "libavutil" = return "ffmpeg"-libNixName "libglade-2.0" = return "libglade" libNixName "libgsasl" = return "gsasl" libNixName "libpcre" = return "pcre" libNixName "libR" = return "R"-libNixName "librsvg-2.0" = return "librsvg"-libNixName "libsoup-2.4" = return "libsoup" libNixName "libsoup-gnome-2.4" = return "libsoup" libNixName "libsystemd" = return "systemd"-libNixName "libusb-1.0" = return "libusb" libNixName "libxml-2.0" = return "libxml2" libNixName "libzip" = return "libzip" libNixName "libzmq" = return "zeromq" libNixName "m" = [] -- in stdenv libNixName "magic" = return "file" libNixName "MagickWand" = return "imagemagick"-libNixName "mono-2.0" = return "mono" libNixName "mpi" = return "openmpi" libNixName "ncursesw" = return "ncurses" libNixName "netsnmp" = return "net_snmp"@@ -127,7 +108,6 @@ libNixName "pfs-1.2" = return "pfstools" libNixName "png" = return "libpng" libNixName "poppler-glib" = return "poppler"-libNixName "portaudio-2.0" = return "portaudio" libNixName "pq" = return "postgresql" libNixName "pthread" = [] libNixName "pulse" = return "libpulseaudio"@@ -144,9 +124,8 @@ libNixName "ruby1.8" = return "ruby" libNixName "sane-backends" = return "saneBackends" libNixName "sass" = return "libsass"-libNixName "sctp" = return "lksctp-tools" -- This is linux-specific, we should create a common attribute if we ever add sctp support for other systems+libNixName "sctp" = return "lksctp-tools" -- This is linux-specific, we should create a common attribute if we ever add sctp support for other systems. libNixName "sdl2" = return "SDL2"-libNixName "SDL2-2.0" = return "SDL2" libNixName "sndfile" = return "libsndfile" libNixName "sodium" = return "libsodium" libNixName "sqlite3" = return "sqlite"@@ -158,13 +137,10 @@ libNixName "tag_c" = return "taglib" libNixName "udev" = return "systemd"; libNixName "uuid" = return "libossp_uuid";-libNixName "vte-2.90" = return "vte"-libNixName "vte-2.91" = return "vte" libNixName "wayland-client" = return "wayland" libNixName "wayland-cursor" = return "wayland" libNixName "wayland-egl" = return "mesa" libNixName "wayland-server" = return "wayland"-libNixName "webkit-1.0" = return "webkit" libNixName "webkit2gtk-4.0" = return "webkit2gtk" libNixName "webkit2gtk-web-extension-4.0" = return "webkit2gtk-web-extension" libNixName "webkitgtk" = return "webkit"@@ -188,7 +164,7 @@ libNixName "yaml-0.1" = return "libyaml" libNixName "z" = return "zlib" libNixName "zmq" = return "zeromq"-libNixName x = return (fromString x)+libNixName x = return (guessNixIdentifier x) -- | Map build tool names to Nix attribute names. buildToolNixName :: String -> [Identifier]@@ -204,3 +180,22 @@ buildToolNixName "nix-instantiate" = return "nix" buildToolNixName "nix-store" = return "nix" buildToolNixName x = return (fromString x)++-- | Helper function to extract the package name from a String that may or may+-- not be formatted like a Cabal package identifier.+--+-- >>> guessNixIdentifier "foo-1.0"+-- Identifier "foo"+-- >>> guessNixIdentifier "foo"+-- Identifier "foo"+-- >>> guessNixIdentifier "foo - 0"+-- Identifier "foo - 0"+-- >>> guessNixIdentifier "1foo-1.0"+-- Identifier "1foo"+-- >>> guessNixIdentifier "-foo-1.0"+-- Identifier "-foo-1.0"++guessNixIdentifier :: String -> Identifier+guessNixIdentifier x = fromString (fromMaybe x maybePackageId)+ where+ maybePackageId = unPackageName . pkgName <$> simpleParse x
src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs view
@@ -17,6 +17,7 @@ & over libraryDepends (normalizeBuildInfo (packageName drv)) & over executableDepends (normalizeBuildInfo (packageName drv)) & over testDepends (normalizeBuildInfo (packageName drv))+ & over benchmarkDepends (normalizeBuildInfo (packageName drv)) & over metaSection normalizeMeta & over cabalFlags normalizeCabalFlags & jailbreak %~ (&& (packageName drv /= PackageName "jailbreak-cabal"))
src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs view
@@ -63,6 +63,7 @@ , ("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", giCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36+ , ("gi-pangocairo", giPangoCairoPhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gi-webkit2", giWebkit2PhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gi-webkit2webextension", giWebkit2PhaseOverrides) -- https://github.com/haskell-gi/haskell-gi/issues/36 , ("gio", set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True)@@ -107,7 +108,6 @@ , ("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"])))- , ("rocksdb-haskell", set (metaSection . platforms) (Set.singleton (Platform X86_64 Linux))) , ("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.@@ -122,6 +122,7 @@ , ("tz", set phaseOverrides "preConfigure = \"export TZDIR=${pkgs.tzdata}/share/zoneinfo\";") , ("websockets", set doCheck False) -- https://github.com/jaspervdj/websockets/issues/104 , ("Win32", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows)))+ , ("Win32-shortcut", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Windows))) , ("wxc", wxcHook) , ("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"])))@@ -310,6 +311,21 @@ txt = unlines [ "preCompileBuildDriver = ''" , " PKG_CONFIG_PATH+=\":${cairo}/lib/pkgconfig\"" , " setupCompileFlags+=\" $(pkg-config --libs cairo-gobject)\""+ , "'';"+ ]++giPangoCairoPhaseOverrides :: Derivation -> Derivation+giPangoCairoPhaseOverrides = set phaseOverrides txt+ . over (libraryDepends . pkgconfig) addPkgs+ where+ addPkgs = Set.union (Set.fromList [ "system-pango = pkgs.pango"+ , "system-cairo = pkgs.cairo" ])+ . Set.insert (pkg "gobjectIntrospection")+ gir = [ "system-pango.dev" ]+ txt = unlines [ "preConfigure = ''" ++ exportGirSearchPath gir ++ "'';"+ , "preCompileBuildDriver = ''"+ , " PKG_CONFIG_PATH+=\":${system-pango.dev}/lib/pkgconfig:${system-cairo.dev}/lib/pkgconfig\""+ , " setupCompileFlags+=\" $(pkg-config --libs pangocairo cairo-gobject)\"" , "'';" ]
+ test/Main.hs view
@@ -0,0 +1,6 @@+module Main ( main ) where++import Test.DocTest++main :: IO ()+main = doctest [ "-isrc", "src" ]