diff --git a/CHANGELOG.md b/CHANGELOG.md
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,63 @@
 # Revision History for cabal2nix
 
+## 2.19.0
+
+Note that some of the API has also changed in a breaking
+manner because of the upgrade to [`distribution-nixpkgs`
+1.7.0](https://github.com/nixos/distribution-nixpkgs/blob/v1.7.0/CHANGELOG.md#170),
+see [#506](https://github.com/NixOS/cabal2nix/pull/506).
+
+* Only use `hpack` when building if no cabal file is found
+  for the package to process.
+  See also [#508](https://github.com/NixOS/cabal2nix/pull/508).
+* `hackage2nix` now supports arbitrary Nix-style platform tuples
+  in `unsupported-platforms` (including the new `aarch64-darwin`) as
+  well as nixpkgs platform groups which are denoted as e. g.
+  `platforms.darwin` and can be used instead of platform tuples.
+  See also [#506](https://github.com/NixOS/cabal2nix/pull/506).
+  **API breaking change**: The `IsString` instance for `Platform` in
+  `Distribution.Nixpkgs.Haskell.OrphanInstances` has been removed.
+* The new `hackage2nix` `supported-platforms` configuration field
+  allows prescribing a specific list of platforms to set in the
+  package's `platforms` meta attribute. `unsupported-platforms`
+  are now translated to `badPlatforms` instead of being subtracted
+  from `platforms`.
+  See also [#506](https://github.com/NixOS/cabal2nix/pull/506)
+  and [#560](https://github.com/NixOS/cabal2nix/pull/560).
+  **API Breaking Change** for
+  `Distribution.Nixpkgs.Haskell.FromCabal.Configuration`.
+* `cabal2nix` will no longer emit a dependency on `webkitgtk24x-gtk{2,3}`
+  if it detects the older 3.0 API of WebKit being used. Nixpkgs hasn't
+  contained this package for a few years now due to security
+  vulnerabilities and the packages still using it on Hackage are
+  unmaintained. If you have a legacy project built with an old
+  version of nixpkgs, either don't upgrade `cabal2nix` or emulate
+  the old behavior using overrides.
+  See also [#521](https://github.com/NixOS/cabal2nix/pull/521).
+* If the input cabal file declares just a single executable, the `mainProgram`
+  meta attribute will be set in the resulting Nix expression.
+  See also [#506](https://github.com/NixOS/cabal2nix/pull/506) and
+  [#557](https://github.com/NixOS/cabal2nix/pull/557).
+* If `cabal2nix` (or `hackage2nix`) doesn't recognize the license
+  of a package, it'll still assume that it's free and enable building
+  on Hydra (i. e. use the default value of `hydraPlatforms`).
+  This is done because Hackage requires uploaded packages to
+  be open source. You may need to keep this change in mind,
+  however, if you use `cabal2nix` for packaging unfree
+  software. See also [#520](https://github.com/NixOS/cabal2nix/pull/520).
+  `isFreeLicense` has changed semantically as a result.
+* Argument parsing logic in `cabal2nix` has been refactored
+  in [#544](https://github.com/NixOS/cabal2nix/pull/544).
+  **API breaking change** for the following modules:
+  
+  * `Cabal2nix`
+  * `Distribution.Nixpkgs.Fetch`
+  * `Distribution.Nixpkgs.Haskell.Derivation` (removed instance)
+  * `Distribution.Nixpkgs.Haskell.PackageSourceSpec`
+* Update handling of Lua bindings to reflect current state upstream.
+  See [#527](https://github.com/NixOS/cabal2nix/pull/527) and
+  [#547](https://github.com/NixOS/cabal2nix/pull/547).
+
 ## 2.18.0
 
 * Support GHC 9.0.x and Cabal 3.4.0.0,
diff --git a/README.md b/README.md
--- a/README.md
+++ b/README.md
@@ -9,17 +9,19 @@
 `cabal2nix` converts a single Cabal file into a single Nix build expression.
 For example:
 
-    $ cabal2nix cabal://mtl
-    { mkDerivation, base, lib, transformers }:
-    mkDerivation {
-      pname = "mtl";
-      version = "2.2.1";
-      sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
-      libraryHaskellDepends = [ base transformers ];
-      homepage = "http://github.com/ekmett/mtl";
-      description = "Monad classes, using functional dependencies";
-      license = lib.licenses.bsd3;
-    }
+```console
+$ cabal2nix cabal://mtl
+{ mkDerivation, base, lib, transformers }:
+mkDerivation {
+  pname = "mtl";
+  version = "2.2.1";
+  sha256 = "1icdbj2rshzn0m1zz5wa7v3xvkf6qw811p4s7jgqwvx1ydwrvrfa";
+  libraryHaskellDepends = [ base transformers ];
+  homepage = "http://github.com/ekmett/mtl";
+  description = "Monad classes, using functional dependencies";
+  license = lib.licenses.bsd3;
+}
+```
 
 Cabal files can be referred to using the magic URL `cabal://NAME-VERSION`,
 which will automatically download the file from Hackage. Alternatively, a
@@ -38,18 +40,20 @@
 most common use-case for this is probably to generate a derivation for a
 project on the local file system:
 
-    $ cabal get mtl-2.2.1 && cd mtl-2.2.1
-    $ cabal2nix .
-    { mkDerivation, base, lib, transformers }:
-    mkDerivation {
-      pname = "mtl";
-      version = "2.2.1";
-      src = ./.;
-      libraryHaskellDepends = [ base transformers ];
-      homepage = "http://github.com/ekmett/mtl";
-      description = "Monad classes, using functional dependencies";
-      license = lib.licenses.bsd3;
-    }
+```console
+$ cabal get mtl-2.2.1 && cd mtl-2.2.1
+$ cabal2nix .
+{ mkDerivation, base, lib, transformers }:
+mkDerivation {
+  pname = "mtl";
+  version = "2.2.1";
+  src = ./.;
+  libraryHaskellDepends = [ base transformers ];
+  homepage = "http://github.com/ekmett/mtl";
+  description = "Monad classes, using functional dependencies";
+  license = lib.licenses.bsd3;
+}
+```
 
 This derivation will not fetch from hackage, but instead use the directory which
 contains the derivation as the source repository.
diff --git a/cabal2nix.cabal b/cabal2nix.cabal
--- a/cabal2nix.cabal
+++ b/cabal2nix.cabal
@@ -1,5 +1,5 @@
 name:               cabal2nix
-version:            2.18.0
+version:            2.19.0
 synopsis:           Convert Cabal files into Nix build instructions.
 description:
   Convert Cabal files into Nix build instructions. Users of Nix can install the latest
@@ -12,7 +12,7 @@
 -- list all contributors: git log --pretty='%an' | sort | uniq
 maintainer:         sternenseemann <sternenseemann@systemli.org>
 stability:          stable
-tested-with:        GHC == 8.10.4 || == 9.0.1
+tested-with:        GHC == 8.8.4 || == 8.10.7 || == 9.0.2
 category:           Distribution, Nix
 homepage:           https://github.com/nixos/cabal2nix#readme
 bug-reports:        https://github.com/nixos/cabal2nix/issues
@@ -44,6 +44,7 @@
                       Distribution.Nixpkgs.Haskell.Hackage
                       Distribution.Nixpkgs.Haskell.OrphanInstances
                       Distribution.Nixpkgs.Haskell.PackageSourceSpec
+                      Distribution.Nixpkgs.Haskell.Platform
   other-modules:      Paths_cabal2nix
   hs-source-dirs:     src
   build-depends:      base                 > 4.11
@@ -56,7 +57,7 @@
                     , containers           >= 0.5.9
                     , deepseq              >= 1.4
                     , directory
-                    , distribution-nixpkgs >= 1.5.0
+                    , distribution-nixpkgs >= 1.7 && <1.8
                     , filepath
                     , hackage-db           >= 2.0.1
                     , hopenssl             >= 2
@@ -100,7 +101,7 @@
                     , cabal2nix
                     , containers
                     , directory
-                    , distribution-nixpkgs >= 1.6
+                    , distribution-nixpkgs >= 1.7 && < 1.8
                     , filepath
                     , hopenssl             >= 2
                     , language-nix
diff --git a/hackage2nix/Main.hs b/hackage2nix/Main.hs
--- a/hackage2nix/Main.hs
+++ b/hackage2nix/Main.hs
@@ -16,13 +16,13 @@
 import Data.Maybe
 import Data.Set ( Set )
 import qualified Data.Set as Set
-import Data.String
 import Distribution.Nixpkgs.Fetch
 import Distribution.Nixpkgs.Haskell as Derivation
 import Distribution.Nixpkgs.Haskell.Constraint
 import Distribution.Nixpkgs.Haskell.FromCabal
 import Distribution.Nixpkgs.Haskell.FromCabal.Configuration as Config
 import Distribution.Nixpkgs.Haskell.FromCabal.Flags
+import Distribution.Nixpkgs.Haskell.Platform ( parsePlatformFromSystemLenient )
 import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
 import Distribution.Nixpkgs.Meta
 import Distribution.Nixpkgs.PackageMap
@@ -62,7 +62,7 @@
         <*> optional (strOption (long "preferred-versions" <> help "path to Hackage preferred-versions file" <> value "hackage/preferred-versions" <> showDefault <> metavar "PATH"))
         <*> strOption (long "nixpkgs" <> help "path to Nixpkgs repository" <> value "nixpkgs" <> showDefaultWith id <> metavar "PATH")
         <*> some1 (strOption (long "config" <> help "path to configuration file inside of Nixpkgs" <> metavar "PATH"))
-        <*> option (fmap fromString str) (long "platform" <> help "target platform to generate package set for" <> value "x86_64-linux" <> showDefaultWith display <> metavar "PLATFORM")
+        <*> option (maybeReader parsePlatformFromSystemLenient) (long "platform" <> help "target platform to generate package set for" <> value (Platform X86_64 Linux) <> showDefaultWith display <> metavar "PLATFORM")
 
       pinfo :: ParserInfo CLI
       pinfo = info
@@ -79,12 +79,10 @@
   nixpkgs <- readNixpkgPackageMap nixpkgsRepository (Just "{ config = { allowAliases = false; }; }")
   preferredVersions <- readPreferredVersions (fromMaybe (hackageRepository </> "preferred-versions") preferredVersionsFile)
   let fixup = Map.delete "acme-everything"      -- TODO: https://github.com/NixOS/cabal2nix/issues/164
-            . 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 "ConcurrentUtils"      -- TODO: depends on "assert"
             . Map.delete "with"                 -- TODO: https://github.com/NixOS/cabal2nix/issues/164
-            . Map.delete "telega"               -- TODO: depends on "with"
             . over (at "hermes") (fmap (set (contains "1.3.4.3") False))  -- TODO: https://github.com/haskell/hackage-server/issues/436
   hackage <- fixup <$> readHackage hackageRepository
   let
@@ -145,9 +143,6 @@
           isHydraEnabled = isInDefaultPackageSet && not (isBroken || name `Set.member` dontDistributePackages config)
           isBroken = any (withinRange v) [ vr | PackageVersionConstraint pn vr <- brokenPackages config, pn == name ]
 
-          droppedPlatforms :: Set Platform
-          droppedPlatforms = Map.findWithDefault mempty name (unsupportedPlatforms config)
-
           tarballSHA256 :: SHA256Hash
           tarballSHA256 = fromMaybe (error (display pkgId ++ ": meta data has no hash for the tarball"))
                                     (view (hashes . at "SHA256") meta)
@@ -162,9 +157,11 @@
           drv = fromGenericPackageDescription haskellResolver nixpkgsResolver targetPlatform (compilerInfo config) flagAssignment [] descr
                   & src .~ urlDerivationSource ("mirror://hackage/" ++ display pkgId ++ ".tar.gz") tarballSHA256
                   & editedCabalFile .~ cabalSHA256
-                  & metaSection.platforms %~ (`Set.difference` Map.findWithDefault Set.empty name (unsupportedPlatforms config))
-                  & metaSection.hydraPlatforms %~ (if Set.null droppedPlatforms then id else (`Set.difference` droppedPlatforms))
-                  & metaSection.hydraPlatforms %~ (if isHydraEnabled then id else const Set.empty)
+                  -- If a list of platforms is set in the hackage2nix configuration file, prefer that.
+                  -- Otherwise a list defined by PostProcess or Nothing is used.
+                  & metaSection.platforms %~ (Map.lookup name (supportedPlatforms config) <|>)
+                  & metaSection.badPlatforms %~ (Map.lookup name (unsupportedPlatforms config) <|>)
+                  & metaSection.hydraPlatforms %~ (if isHydraEnabled then id else const (Just Set.empty))
                   & metaSection.broken ||~ isBroken
                   & metaSection.maintainers .~ Map.findWithDefault Set.empty name globalPackageMaintainers
                   & metaSection.homepage .~ ""
diff --git a/src/Cabal2nix.hs b/src/Cabal2nix.hs
--- a/src/Cabal2nix.hs
+++ b/src/Cabal2nix.hs
@@ -1,6 +1,7 @@
 {-# LANGUAGE LambdaCase #-}
 {-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE RecordWildCards #-}
+{-# LANGUAGE ApplicativeDo #-}
 
 module Cabal2nix
   ( main, cabal2nix, cabal2nix', cabal2nixWithDB, parseArgs
@@ -11,9 +12,7 @@
 import Control.Exception ( bracket )
 import Control.Lens
 import Control.Monad
-import Data.List ( intercalate, isPrefixOf )
-import Data.List.Split
-import Data.Maybe ( fromMaybe, isJust, listToMaybe )
+import Data.Maybe ( fromMaybe, isJust )
 import qualified Data.Set as Set
 import Data.String
 import Data.Time
@@ -22,6 +21,7 @@
 import Distribution.Nixpkgs.Haskell
 import Distribution.Nixpkgs.Haskell.FromCabal
 import Distribution.Nixpkgs.Haskell.FromCabal.Flags
+import Distribution.Nixpkgs.Haskell.Platform
 import qualified Distribution.Nixpkgs.Haskell.FromCabal.PostProcess as PP (pkg)
 import qualified Distribution.Nixpkgs.Haskell.Hackage as DB
 import Distribution.Nixpkgs.Haskell.OrphanInstances ( )
@@ -66,42 +66,66 @@
   , optHackageSnapshot :: Maybe UTCTime
   , optNixpkgsIdentifier :: NixpkgsResolver
   , optUrl :: String
-  , optFetchSubmodules :: Bool
+  , optFetchSubmodules :: FetchSubmodules
   }
 
 options :: Parser Options
-options = Options
-          <$> optional (strOption $ long "sha256" <> metavar "HASH" <> help "sha256 hash of source tarball")
-          <*> many (strOption $ long "maintainer" <> metavar "MAINTAINER" <> help "maintainer of this package (may be specified multiple times)")
---        <*> many (strOption $ long "platform" <> metavar "PLATFORM" <> help "supported build platforms (may be specified multiple times)")
-          <*> flag True False (long "no-haddock" <> help "don't run Haddock when building this package")
-          <*>
-          (
-            flag' ForceHpack (long "hpack" <> help "run hpack before configuring this package (only non-hackage packages)")
-            <|>
-            flag' NoHpack (long "no-hpack" <> help "disable hpack run and use only cabal disregarding package.yaml existence")
-            <|>
-            pure PackageYamlHpack
-          )
-          <*> flag True False (long "no-check" <> help "don't run regression test suites of this package")
-          <*> switch (long "jailbreak" <> help "disregard version restrictions on build inputs")
-          <*> switch (long "benchmark" <> help "enable benchmarks for this package")
-          <*> optional (strOption $ long "revision" <> help "revision to use when fetching from VCS")
-          <*> flag True False (long "no-hyperlink-source" <> help "don't generate pretty-printed source code for the documentation")
-          <*> switch (long "enable-library-profiling" <> help "enable library profiling in the generated build")
-          <*> switch (long "enable-executable-profiling" <> help "enable executable profiling in the generated build")
-          <*> optional (switch (long "enable-profiling" <> help "enable both library and executable profiling in the generated build"))
-          <*> many (strOption $ long "extra-arguments" <> help "extra parameters required for the function body")
-          <*> optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
-          <*> switch (long "shell" <> help "generate output suitable for nix-shell")
-          <*> many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
-          <*> option parseCabal (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith prettyShow)
-          <*> option (maybeReader parsePlatform) (long "system" <> help "host system (in either short Nix format or full LLVM style) to use when evaluating the Cabal file" <> value buildPlatform <> showDefaultWith prettyShow)
-          <*> optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
-          <*> optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
-          <*> pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
-          <*> strArgument (metavar "URI")
-          <*> flag True False (long "dont-fetch-submodules" <> help "do not fetch git submodules from git sources")
+options = do
+  optSha256
+    <- optional (strOption $ long "sha256" <> metavar "HASH" <> help "sha256 hash of source tarball")
+  optMaintainer
+    <- many (strOption $ long "maintainer" <> metavar "MAINTAINER" <> help "maintainer of this package (may be specified multiple times)")
+-- optPlatform <- many (strOption $ long "platform" <> metavar "PLATFORM" <> help "supported build platforms (may be specified multiple times)")
+  optHaddock
+    <- flag True False (long "no-haddock" <> help "don't run Haddock when building this package")
+  optHpack
+    <-
+      (
+        flag' ForceHpack (long "hpack" <> help "run hpack before configuring this package (only non-hackage packages)")
+        <|>
+        flag' NoHpack (long "no-hpack" <> help "disable hpack run and use only cabal disregarding package.yaml existence")
+        <|>
+        pure PackageYamlHpack
+      )
+  optDoCheck
+    <- flag True False (long "no-check" <> help "don't run regression test suites of this package")
+  optJailbreak
+    <- switch (long "jailbreak" <> help "disregard version restrictions on build inputs")
+  optDoBenchmark
+    <- switch (long "benchmark" <> help "enable benchmarks for this package")
+  optRevision
+    <- optional (strOption $ long "revision" <> help "revision to use when fetching from VCS")
+  optHyperlinkSource
+    <- flag True False (long "no-hyperlink-source" <> help "don't generate pretty-printed source code for the documentation")
+  optEnableLibraryProfiling
+    <- switch (long "enable-library-profiling" <> help "enable library profiling in the generated build")
+  optEnableExecutableProfiling
+    <- switch (long "enable-executable-profiling" <> help "enable executable profiling in the generated build")
+  optEnableProfiling
+    <- optional (switch (long "enable-profiling" <> help "enable both library and executable profiling in the generated build"))
+  optExtraArgs
+    <- many (strOption $ long "extra-arguments" <> help "extra parameters required for the function body")
+  optHackageDb
+    <- optional (strOption $ long "hackage-db" <> metavar "PATH" <> help "path to the local hackage db in tar format")
+  optNixShellOutput
+    <- switch (long "shell" <> help "generate output suitable for nix-shell")
+  optFlags
+    <- many (strOption $ short 'f' <> long "flag" <> help "Cabal flag (may be specified multiple times)")
+  optCompiler
+    <- option parseCabal (long "compiler" <> help "compiler to use when evaluating the Cabal file" <> value buildCompilerId <> showDefaultWith prettyShow)
+  optSystem
+    <- option (maybeReader parsePlatformLenient) (long "system" <> help "host system (in either short Nix format or full LLVM style) to use when evaluating the Cabal file" <> value buildPlatform <> showDefaultWith prettyShow)
+  optSubpath
+    <- optional (strOption $ long "subpath" <> metavar "PATH" <> help "Path to Cabal file's directory relative to the URI (default is root directory)")
+  optHackageSnapshot
+    <- optional (option utcTimeReader (long "hackage-snapshot" <> help "hackage snapshot time, ISO format"))
+  optNixpkgsIdentifier
+    <- pure (\i -> Just (binding # (i, path # [ident # "pkgs", i])))
+  optUrl
+    <- strArgument (metavar "URI")
+  optFetchSubmodules
+    <- flag FetchSubmodules DontFetchSubmodules  (long "dont-fetch-submodules" <> help "do not fetch git submodules from git sources")
+  pure Options{..}
 
 -- | A parser for the date. Hackage updates happen maybe once or twice a month.
 -- Example: parseTime defaultTimeLocale "%FT%T%QZ" "2017-11-20T12:18:35Z" :: Maybe UTCTime
@@ -114,53 +138,6 @@
 parseCabal :: Parsec a => ReadM a
 parseCabal = eitherReader eitherParsec
 
--- | Replicate the normalization performed by GHC_CONVERT_CPU in GHC's aclocal.m4
--- since the output of that is what Cabal parses.
-ghcConvertArch :: String -> String
-ghcConvertArch arch = case arch of
-  "i486"  -> "i386"
-  "i586"  -> "i386"
-  "i686"  -> "i386"
-  "amd64" -> "x86_64"
-  _ -> fromMaybe arch $ listToMaybe
-    [prefix | prefix <- archPrefixes, prefix `isPrefixOf` arch]
-  where archPrefixes =
-          [ "aarch64", "alpha", "arm", "hppa1_1", "hppa", "m68k", "mipseb"
-          , "mipsel", "mips", "powerpc64le", "powerpc64", "powerpc", "s390x"
-          , "sparc64", "sparc"
-          ]
-
--- | Replicate the normalization performed by GHC_CONVERT_OS in GHC's aclocal.m4
--- since the output of that is what Cabal parses.
-ghcConvertOS :: String -> String
-ghcConvertOS os = case os of
-  "watchos"       -> "ios"
-  "tvos"          -> "ios"
-  "linux-android" -> "linux-android"
-  "linux-androideabi" -> "linux-androideabi"
-  _ | "linux-" `isPrefixOf` os -> "linux"
-  _ -> fromMaybe os $ listToMaybe
-    [prefix | prefix <- osPrefixes, prefix `isPrefixOf` os]
-  where osPrefixes =
-          [ "gnu", "openbsd", "aix", "darwin", "solaris2", "freebsd", "nto-qnx"]
-
-parseArch :: String -> Arch
-parseArch = classifyArch Permissive . ghcConvertArch
-
-parseOS :: String -> OS
-parseOS = classifyOS Permissive . ghcConvertOS
-
-parsePlatform :: String -> Maybe Platform
-parsePlatform = parsePlatformParts . splitOn "-"
-
-parsePlatformParts :: [String] -> Maybe Platform
-parsePlatformParts = \case
-  [arch, os] ->
-    Just $ Platform (parseArch arch) (parseOS os)
-  (arch : _ : osParts) ->
-    Just $ Platform (parseArch arch) $ parseOS $ intercalate "-" osParts
-  _ -> Nothing
-
 pinfo :: ParserInfo Options
 pinfo = info
         (   helper
@@ -199,7 +176,14 @@
 cabal2nix' :: Options -> IO (Either Doc Derivation)
 cabal2nix' opts@Options{..} = do
   pkg <- getPackage optHpack optFetchSubmodules optHackageDb optHackageSnapshot $
-         Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
+         Source {
+           sourceUrl = optUrl,
+           sourceRevision = fromMaybe "" optRevision,
+           sourceHash = case optSha256 of
+             Nothing -> UnknownHash
+             Just hash -> Guess hash,
+           sourceCabalDir = fromMaybe "" optSubpath
+         }
   processPackage opts pkg
 
 cabal2nixWithDB :: DB.HackageDB -> Options -> IO (Either Doc Derivation)
@@ -207,7 +191,14 @@
   when (isJust optHackageDb) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-db"
   when (isJust optHackageSnapshot) $ hPutStrLn stderr "WARN: HackageDB provided directly; ignoring --hackage-snapshot"
   pkg <- getPackage' optHpack optFetchSubmodules (return db) $
-         Source optUrl (fromMaybe "" optRevision) (maybe UnknownHash Guess optSha256) (fromMaybe "" optSubpath)
+         Source {
+           sourceUrl = optUrl,
+           sourceRevision = fromMaybe "" optRevision,
+           sourceHash = case optSha256 of
+             Nothing -> UnknownHash
+             Just hash -> Guess hash,
+           sourceCabalDir = fromMaybe "" optSubpath
+         }
   processPackage opts pkg
 
 processPackage :: Options -> Package -> IO (Either Doc Derivation)
diff --git a/src/Distribution/Nixpkgs/Fetch.hs b/src/Distribution/Nixpkgs/Fetch.hs
--- a/src/Distribution/Nixpkgs/Fetch.hs
+++ b/src/Distribution/Nixpkgs/Fetch.hs
@@ -2,11 +2,16 @@
 {-# LANGUAGE RecordWildCards #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE DeriveGeneric #-}
+{-# LANGUAGE LambdaCase #-}
 
 module Distribution.Nixpkgs.Fetch
   ( Source(..)
   , Hash(..)
   , DerivationSource(..), fromDerivationSource, urlDerivationSource
+  , DerivKind(..)
+  , derivKindFunction
+  , FetchSubmodules(..)
+  , UnpackArchive(..)
   , fetch
   , fetchWith
   ) where
@@ -55,13 +60,13 @@
 -- | A source for a derivation. It always needs a hash and also has a protocol attached to it (url, git, svn, ...).
 -- A @DerivationSource@ also always has it's revision fully resolved (not relative revisions like @master@, @HEAD@, etc).
 data DerivationSource = DerivationSource
-  { derivKind     :: String -- ^ The kind of the source. The name of the build-support fetch derivation should be fetch<kind>.
+  { derivKind     :: Maybe DerivKind -- ^ The kind of the source. If Nothing, it is a local derivation.
   , derivUrl      :: String -- ^ URL to fetch from.
   , derivRevision :: String -- ^ Revision to use. Leave empty if the fetcher doesn't support revisions.
   , derivHash     :: String -- ^ The hash of the source.
   , derivSubmodule :: Maybe Bool -- ^ The fetchSubmodule setting (if any)
   }
-  deriving (Show, Eq, Ord, Generic)
+  deriving (Show, Generic)
 
 instance NFData DerivationSource
 
@@ -76,11 +81,11 @@
 instance PP.Pretty DerivationSource where
   pPrint DerivationSource {..} =
     let isHackagePackage = "mirror://hackage/" `L.isPrefixOf` derivUrl
-        fetched = derivKind /= ""
     in if isHackagePackage then if derivHash /= "" then attr "sha256" $ string derivHash else mempty
-       else if not fetched then attr "src" $ text derivUrl
-            else vcat
-                 [ text "src" <+> equals <+> text ("fetch" ++ derivKind) <+> lbrace
+       else case derivKind of
+          Nothing ->  attr "src" $ text derivUrl
+          Just derivKind' -> vcat
+                 [ text "src" <+> equals <+> text (derivKindFunction derivKind') <+> lbrace
                  , nest 2 $ vcat
                    [ attr "url" $ string derivUrl
                    , attr "sha256" $ string derivHash
@@ -92,28 +97,45 @@
 
 
 urlDerivationSource :: String -> String -> DerivationSource
-urlDerivationSource url hash = DerivationSource "url" url "" hash Nothing
+urlDerivationSource url hash =
+  DerivationSource {
+    derivKind = Just (DerivKindUrl DontUnpackArchive),
+    derivUrl = url,
+    derivRevision = "",
+    derivHash = hash,
+    derivSubmodule = Nothing
+  }
 
 fromDerivationSource :: DerivationSource -> Source
-fromDerivationSource DerivationSource{..} = Source derivUrl derivRevision (Certain derivHash) "."
+fromDerivationSource DerivationSource{..} =
+  Source {
+    sourceUrl = derivUrl,
+    sourceRevision = derivRevision,
+    sourceHash = Certain derivHash,
+    sourceCabalDir = "."
+  }
 
 -- | Fetch a source, trying any of the various nix-prefetch-* scripts.
 fetch :: forall a.
-         Bool                                   -- ^ If True, fetch submodules when the source is a git repository
-      -> (String -> MaybeT IO a)                -- ^ This function is passed the output path name as an argument.
-                                                -- It should return 'Nothing' if the file doesn't match the expected format.
-                                                -- This is required, because we cannot always check if a download succeeded otherwise.
-      -> Source                                 -- ^ The source to fetch from.
-      -> IO (Maybe (DerivationSource, a))       -- ^ The derivation source and the result of the processing function. Returns Nothing if the download failed.
+         FetchSubmodules
+      -- ^ whether to fetch submodules when the source is a git repository
+      -> (String -> MaybeT IO a)
+      -- ^ This function is passed the output path name as an argument.
+      -- It should return 'Nothing' if the file doesn't match the expected format.
+      -- This is required, because we cannot always check if a download succeeded otherwise.
+      -> Source
+      -- ^ The source to fetch from.
+      -> IO (Maybe (DerivationSource, a))
+      -- ^ The derivation source and the result of the processing function. Returns Nothing if the download failed.
 fetch optSubModules f = runMaybeT . fetchers where
   fetchers :: Source -> MaybeT IO (DerivationSource, a)
   fetchers source = msum . (fetchLocal source :) $ map (\fetcher -> fetchWith fetcher source >>= process)
-    [ (False, "url", Nothing, [])
-    , (False, "zip", Just "nix-prefetch-url", ["--unpack"])
-    , (True, "git", Nothing, ["--fetch-submodules" | optSubModules ])
-    , (True, "hg", Nothing, [])
-    , (True, "svn", Nothing, [])
-    , (True, "bzr", Nothing, [])
+    [ (False, DerivKindUrl DontUnpackArchive)
+    , (False, DerivKindUrl UnpackArchive)
+    , (True, DerivKindGit optSubModules)
+    , (True, DerivKindHg)
+    , (True, DerivKindSvn)
+    , (True, DerivKindBzr)
     ]
 
   -- | Remove '/' from the end of the path. Nix doesn't accept paths that
@@ -134,28 +156,96 @@
   localArchive :: FilePath -> MaybeT IO (DerivationSource, a)
   localArchive path = do
     absolutePath <- liftIO $ canonicalizePath path
-    unpacked <- snd <$> fetchWith (False, "url", Nothing, ["--unpack"]) (Source ("file://" ++ absolutePath) "" UnknownHash ".")
+    unpacked <-
+      snd <$>
+        fetchWith
+          (False, DerivKindUrl UnpackArchive)
+          (Source {
+            sourceUrl = "file://" ++ absolutePath,
+            sourceRevision = "",
+            sourceHash = UnknownHash,
+            sourceCabalDir = "."
+          })
     process (localDerivationSource absolutePath, unpacked)
 
   process :: (DerivationSource, FilePath) -> MaybeT IO (DerivationSource, a)
   process (derivSource, file) = (,) derivSource <$> f file
 
-  localDerivationSource p = DerivationSource "" p "" "" Nothing
+  localDerivationSource p =
+    DerivationSource {
+      derivKind = Nothing,
+      derivUrl = p,
+      derivRevision = "",
+      derivHash = "",
+      derivSubmodule = Nothing
+    }
 
+data DerivKind
+  = DerivKindUrl UnpackArchive
+  | DerivKindGit FetchSubmodules
+  | DerivKindHg
+  | DerivKindSvn
+  | DerivKindBzr
+  deriving (Show, Generic)
+
+instance NFData DerivKind
+
+-- | Whether to fetch submodules (git).
+data FetchSubmodules = FetchSubmodules | DontFetchSubmodules
+  deriving (Show, Generic)
+
+instance NFData FetchSubmodules
+
+
+-- | Whether to unpack an archive after fetching, before putting it into the nix store.
+data UnpackArchive = UnpackArchive | DontUnpackArchive
+  deriving (Show, Generic)
+
+instance NFData UnpackArchive
+
+
+-- | The nixpkgs function to use for fetching this kind of derivation
+derivKindFunction :: DerivKind -> String
+derivKindFunction = \case
+  DerivKindUrl DontUnpackArchive -> "fetchurl"
+  DerivKindUrl UnpackArchive -> "fetchzip"
+  DerivKindGit _ -> "fetchgit"
+  DerivKindHg -> "fetchhg"
+  DerivKindSvn -> "fetchsvn"
+  DerivKindBzr -> "fetchbzr"
+
+
 -- | Like 'fetch', but allows to specify which script to use.
-fetchWith :: (Bool, String, Maybe String, [String]) -> Source -> MaybeT IO (DerivationSource, FilePath)
-fetchWith (supportsRev, kind, command, addArgs) source = do
+fetchWith :: (Bool, DerivKind) -> Source -> MaybeT IO (DerivationSource, FilePath)
+fetchWith (supportsRev, kind) source = do
   unless ((sourceRevision source /= "") || isUnknown (sourceHash source) || not supportsRev) $
     liftIO (hPutStrLn stderr "** need a revision for VCS when the hash is given. skipping.") >> mzero
 
+  let (script, extraArgs) = case kind of
+        DerivKindUrl UnpackArchive ->  ("nix-prefetch-url", ["--unpack"])
+        DerivKindUrl DontUnpackArchive ->  ("nix-prefetch-url", [])
+        DerivKindGit FetchSubmodules -> ("nix-prefetch-git", ["--fetch-submodules"])
+        DerivKindGit DontFetchSubmodules -> ("nix-prefetch-git", [])
+        DerivKindHg -> ("nix-prefetch-hg", [])
+        DerivKindSvn -> ("nix-prefetch-svn", [])
+        DerivKindBzr -> ("nix-prefetch-bzr", [])
+
+  let args :: [String] =
+            extraArgs
+         ++ sourceUrl source
+         : [ sourceRevision source | supportsRev ]
+         ++ hashToList (sourceHash source)
+
   MaybeT $ liftIO $ do
     envs <- getEnvironment
-    (Nothing, Just stdoutH, _, processH) <- createProcess (proc script args)
-      { env = Just $ ("PRINT_PATH", "1") : envs
-      , std_in = Inherit
-      , std_err = Inherit
-      , std_out = CreatePipe
-      }
+    (Nothing, Just stdoutH, _, processH) <-
+      createProcess
+        (proc script args)
+        { env = Just $ ("PRINT_PATH", "1") : envs
+        , std_in = Inherit
+        , std_err = Inherit
+        , std_out = CreatePipe
+        }
 
     exitCode <- waitForProcess processH
     case exitCode of
@@ -168,7 +258,7 @@
             buf'   = BS.unlines (reverse ls)
         case length ls of
           0 -> return Nothing
-          1 -> return (Just (DerivationSource { derivKind = kind
+          1 -> return (Just (DerivationSource { derivKind = Just kind
                                               , derivUrl = sourceUrl source
                                               , derivRevision = ""
                                               , derivHash = BS.unpack (head ls)
@@ -177,14 +267,8 @@
                             , BS.unpack l))
           _ -> case eitherDecode buf' of
                  Left err -> error ("invalid JSON: " ++ err ++ " in " ++ show buf')
-                 Right ds -> return (Just (ds { derivKind = kind }, BS.unpack l))
- where
-
-   script :: String
-   script = fromMaybe ("nix-prefetch-" ++ kind) command
+                 Right ds -> return (Just (ds { derivKind = Just kind }, BS.unpack l))
 
-   args :: [String]
-   args = addArgs ++ sourceUrl source : [ sourceRevision source | supportsRev ] ++ hashToList (sourceHash source)
 
 stripPrefix :: Eq a => [a] -> [a] -> [a]
 stripPrefix prefix as
diff --git a/src/Distribution/Nixpkgs/Haskell/Derivation.hs b/src/Distribution/Nixpkgs/Haskell/Derivation.hs
--- a/src/Distribution/Nixpkgs/Haskell/Derivation.hs
+++ b/src/Distribution/Nixpkgs/Haskell/Derivation.hs
@@ -66,7 +66,7 @@
   , _enableSeparateDataOutput   :: Bool
   , _metaSection                :: Meta
   }
-  deriving (Show, Eq, Generic)
+  deriving (Show, Generic)
 
 nullDerivation :: Derivation
 nullDerivation = MkDerivation
@@ -147,7 +147,9 @@
       inputs :: Set String
       inputs = Set.unions [ Set.map (view (localName . ident)) _extraFunctionArgs
                           , setOf (dependencies . each . folded . localName . ident) drv
-                          , Set.fromList ["fetch" ++ derivKind _src | derivKind _src /= "" && not isHackagePackage]
+                          , case derivKind _src of
+                              Nothing -> mempty
+                              Just derivKind' -> Set.fromList [derivKindFunction derivKind' | not isHackagePackage]
                           ]
 
       renderedFlags = [ text "-f" <> (if enable then empty else char '-') <> text (unFlagName f) | (f, enable) <- unFlagAssignment _cabalFlags ]
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal.hs
@@ -132,8 +132,10 @@
                      & Nix.description .~ stripRedundanceSpaces synopsis
 #endif
                      & Nix.license .~ nixLicense
-                     & Nix.platforms .~ Nix.allKnownPlatforms
-                     & Nix.hydraPlatforms .~ (if isFreeLicense nixLicense then Nix.allKnownPlatforms else Set.empty)
+                     & Nix.platforms .~ Nothing
+                     & Nix.badPlatforms .~ Nothing
+                     & Nix.hydraPlatforms .~ (if isFreeLicense nixLicense then Nothing else Just Set.empty)
+                     & Nix.mainProgram .~ nixMainProgram
                      & Nix.maintainers .~ mempty
                      & Nix.broken .~ not (null missingDeps)
                      )
@@ -142,6 +144,14 @@
 
     nixLicense :: Nix.License
     nixLicense =  either fromSPDXLicense fromCabalLicense licenseRaw
+
+    -- return the name of the executable if there is exactly one. If more,
+    -- it is hard to decide automatically which should be the default/main one.
+    nixMainProgram :: Maybe String
+    nixMainProgram =
+      case filter (buildable . buildInfo) executables of
+        [mainProgram] -> Just $ unUnqualComponentName $ exeName mainProgram
+        _ -> Nothing
 
     resolveInHackage :: Identifier -> Binding
     resolveInHackage i | (i^.ident) `elem` [ unPackageName n | (Dependency n _ _) <- missingDeps ] = bindNull i
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Configuration.hs
@@ -23,6 +23,7 @@
 import Data.Yaml
 import Distribution.Compiler
 import Distribution.Nixpkgs.Haskell.Constraint
+import Distribution.Nixpkgs.Meta
 import Distribution.Package
 import Distribution.System
 import GHC.Generics ( Generic )
@@ -49,8 +50,11 @@
   -- 'maintainers' for a given Haskell package.
   , packageMaintainers :: Map Identifier (Set PackageName)
 
+  -- |These packages (necessarily) only support a certain list of platforms.
+  , supportedPlatforms :: Map PackageName (Set NixpkgsPlatform)
+
   -- |These packages (by design) don't support certain platforms.
-  , unsupportedPlatforms :: Map PackageName (Set Platform)
+  , unsupportedPlatforms :: Map PackageName (Set NixpkgsPlatform)
 
   -- |These packages cannot be distributed by Hydra, i.e. because they have an
   -- unfree license or depend on other tools that cannot be distributed for
@@ -72,6 +76,7 @@
                          , defaultPackageOverrides = defaultPackageOverrides l <> defaultPackageOverrides r
                          , extraPackages = extraPackages l <> extraPackages r
                          , packageMaintainers = packageMaintainers l <> packageMaintainers r
+                         , supportedPlatforms = supportedPlatforms l <> supportedPlatforms r
                          , unsupportedPlatforms = unsupportedPlatforms l <> unsupportedPlatforms r
                          , dontDistributePackages = dontDistributePackages l <> dontDistributePackages r
                          , brokenPackages = brokenPackages l <> brokenPackages r
@@ -84,6 +89,7 @@
         <*> o .:? "default-package-overrides" .!= mempty
         <*> o .:? "extra-packages" .!= mempty
         <*> o .:? "package-maintainers" .!= mempty
+        <*> o .:? "supported-platforms" .!= mempty
         <*> o .:? "unsupported-platforms" .!= mempty
         <*> o .:? "dont-distribute-packages" .!= mempty
         <*> o .:? "broken-packages" .!= mempty
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Flags.hs
@@ -43,11 +43,14 @@
  | name == "hlibsass" && version >= mkVersion [0,1,5]
                                 = [enable "externalLibsass"]
  | name == "hmatrix"            = [enable "openblas", enable "disable-default-paths"]
- | name == "hslua"              = [enable "system-lua", disable "use-pkgconfig"]
+ | name == "hslua" && version < mkVersion [2,0,0]
+                                = [enable "system-lua", disable "use-pkgconfig"]
  | name == "idris"              = [enable "gmp", enable "ffi", enable "curses", ("execonly", version `withinRange` orLaterVersion (mkVersion [1,1,1])) ]
  | name == "io-streams"         = [enable "NoInteractiveTests"]
  | name == "liquid-fixpoint"    = [enable "build-external"]
- | name == "pandoc"             = [enable "https", disable "trypandoc"]
+ | name == "lua" && version >= mkVersion [2,0,0]
+                                = [enable "system-lua", disable "use-pkgconfig"]
+ | name == "pandoc"             = [disable "trypandoc"]
  | name == "pandoc-placetable"  = [enable "inlineMarkdown"]
  | name == "persistent-sqlite"  = [enable "systemlib"]
  | name == "reactive-banana-wx" = [disable "buildExamples"]
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/License.hs
@@ -163,7 +163,17 @@
       -- Use the SPDX expression as a free-form license string.
       Unknown (Just $ prettyShow expr)
 
+-- "isFreeLicense" is used to determine whether we generate a "hydraPlatforms =
+-- none" in the hackage2nix output for a package with the given license.
+
+-- Note: If "isFreeLicense" returned false for a license which is not an unfree
+-- license from "lib.licenses" the package would still be build by hydra if
+-- another package depended on it.
+
+-- Since all software on hackage needs to be "open source in spirit" and we
+-- don‘t know any software on hackage for which we are not allowed to
+-- distribute binary outputs we assume that a package has a free license if we
+-- don‘t explicitly know otherwise.
 isFreeLicense :: Distribution.Nixpkgs.License.License -> Bool
 isFreeLicense (Known "lib.licenses.unfree") = False
-isFreeLicense (Unknown Nothing)             = False
 isFreeLicense _                             = True
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Name.hs
@@ -45,6 +45,7 @@
 libNixName "ff"                                 = return "libff"
 libNixName "fftw3"                              = return "fftw"
 libNixName "fftw3f"                             = return "fftwFloat"
+libNixName "freetype2"                          = return "freetype"
 libNixName "gconf"                              = return "GConf"
 libNixName "gconf-2.0"                          = return "GConf"
 libNixName "gdk-2.0"                            = return "gtk2"
@@ -55,6 +56,7 @@
 libNixName "gdk-x11-3.0"                        = return "gtk3"
 libNixName "gio-2.0"                            = return "glib"
 libNixName "GL"                                 = return "libGL"
+libNixName "GLEW"                               = return "glew"
 libNixName "GLU"                                = ["libGLU","libGL"]
 libNixName "glut"                               = ["freeglut","libGLU","libGL"]
 libNixName "gnome-keyring"                      = return "gnome-keyring"
@@ -87,7 +89,6 @@
 libNixName "Imlib2"                             = return "imlib2"
 libNixName "iw"                                 = return "wirelesstools"
 libNixName "jack"                               = return "libjack2"
-libNixName "javascriptcoregtk-3.0"              = return "webkitgtk24x-gtk3"    -- These are the old APIs, of which 2.4 is the last provider, so map directly to that.
 libNixName "javascriptcoregtk-4.0"              = return "webkitgtk"
 libNixName "jpeg"                               = return "libjpeg"
 libNixName "jvm"                                = return "jdk"
@@ -120,6 +121,7 @@
 libNixName "mysql"                              = return "mariadb"
 libNixName "ncursesw"                           = return "ncurses"
 libNixName "netsnmp"                            = return "net_snmp"
+libNixName "nix-cmd"                            = return "nix"
 libNixName "nix-expr"                           = return "nix"
 libNixName "nix-main"                           = return "nix"
 libNixName "nix-store"                          = return "nix"
@@ -171,10 +173,10 @@
 libNixName "wayland-cursor"                     = return "wayland"
 libNixName "wayland-egl"                        = return "libGL"
 libNixName "wayland-server"                     = return "wayland"
+libNixName "webkit"                             = return "webkitgtk"
 libNixName "webkit2gtk"                         = return "webkitgtk"
 libNixName "webkit2gtk-4.0"                     = return "webkitgtk"
 libNixName "webkit2gtk-web-extension-4.0"       = return "webkitgtk"
-libNixName "webkitgtk-3.0"                      = return "webkitgtk24x-gtk3"     -- These are the old APIs, of which 2.4 is the last provider, so map directly to that
 libNixName "X11"                                = return "libX11"
 libNixName "x11"                                = return "xlibsWrapper"
 libNixName "xau"                                = return "libXau"
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/Normalize.hs
@@ -27,8 +27,7 @@
 normalizeMeta :: Meta -> Meta
 normalizeMeta meta = meta
   & description %~ normalizeSynopsis
-  & platforms %~ Set.intersection allKnownPlatforms
-  & hydraPlatforms %~ (if meta^.broken then const Set.empty else Set.intersection (meta^.platforms))
+  & hydraPlatforms %~ (if meta^.broken then const (Just Set.empty) else id)
 
 normalizeSynopsis :: String -> String
 normalizeSynopsis desc
diff --git a/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs b/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
--- a/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
+++ b/src/Distribution/Nixpkgs/Haskell/FromCabal/PostProcess.hs
@@ -15,7 +15,6 @@
 import Distribution.Nixpkgs.Meta
 import Distribution.Nixpkgs.License
 import Distribution.Package
-import Distribution.System
 import Distribution.Types.PackageVersionConstraint
 import Distribution.Text
 import Distribution.Version
@@ -78,9 +77,9 @@
   , ("Agda >= 2.6", set (executableDepends . tool . contains (pkg "emacs")) True)
   , ("alex < 3.1.5",  set (testDepends . tool . contains (pkg "perl")) True)
   , ("alex",  set (executableDepends . tool . contains (self "happy")) True)
-  , ("alsa-core", over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == Linux)))
+  , ("alsa-core", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "linux"))))
   , ("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)))
+  , ("bindings-lxc", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "linux"))))
   , ("bustle", bustleOverrides)
   , ("Cabal", set doCheck False) -- test suite doesn't work in Nix
   , ("Cabal >2.2", over (setupDepends . haskell) (Set.union (Set.fromList [self "mtl", self "parsec"]))) -- https://github.com/haskell/cabal/issues/5391
@@ -91,7 +90,7 @@
   , ("dbus", set doCheck False) -- don't execute tests that try to access the network
   , ("dhall", set doCheck False) -- attempts to access the network
   , ("dns", set testTarget "spec")      -- don't execute tests that try to access the network
-  , ("eventstore", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64)))
+  , ("eventstore", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "x86_64"))))
   , ("freenect < 1.2.1", over configureFlags (Set.union (Set.fromList ["--extra-include-dirs=${pkgs.freenect}/include/libfreenect", "--extra-lib-dirs=${pkgs.freenect}/lib"])))
   , ("fltkhs", set (libraryDepends . system . contains (pkg "fltk14")) True . over (libraryDepends . pkgconfig) (Set.union (pkgs ["libGLU", "libGL"]))) -- TODO: fltk14 belongs into the *setup* dependencies.
   , ("gf", set phaseOverrides gfPhaseOverrides . set doCheck False)
@@ -104,12 +103,10 @@
   , ("gi-gstbase", giGstLibOverrides "gst-plugins-base")    -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gi-gstvideo", giGstLibOverrides "gst-plugins-base")   -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gi-gtk", set runHaddock True )
-  , ("gi-javascriptcore < 4.0.0.0", webkitgtk24xHook)       -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gi-pango", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gi-pango", set runHaddock True )
   , ("gi-pangocairo", giCairoPhaseOverrides)                     -- https://github.com/haskell-gi/haskell-gi/issues/36
   , ("gi-vte", set runHaddock True )
-  , ("gi-webkit", webkitgtk24xHook)   -- 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
   , ("git-annex >= 6.20170925 && < 6.20171214", set doCheck False)      -- some versions of git-annex require their test suite to be run inside of a git checkout
@@ -131,7 +128,7 @@
   , ("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 < 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_1")))
-  , ("hslua >= 0.9.3", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
+  , ("hslua >= 0.9.3 && < 2.0.0", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
   , ("hspec-core >= 2.4.4", hspecCoreOverrides)
   , ("http-client", set doCheck False)          -- attempts to access the network
   , ("http-client-openssl >= 0.2.0.1", set doCheck False) -- attempts to access the network
@@ -144,7 +141,9 @@
   , ("libxml", set (configureFlags . contains "--extra-include-dir=${libxml2.dev}/include/libxml2") True)
   , ("liquid-fixpoint", 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 (self "only-buildable-on-windows")) False)
+  , ("lua >= 2.0.0 && < 2.2.0", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_3")))
+  , ("lua >= 2.2.0", over (libraryDepends . system) (replace (pkg "lua") (pkg "lua5_4")))
+  , ("lzma-clib", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "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 "libmysqlclient")) True)
@@ -163,7 +162,7 @@
   , ("readline", over (libraryDepends . system) (Set.union (pkgs ["readline", "ncurses"])))
   , ("req", set doCheck False)  -- test suite requires network access
   , ("sbv > 7", set (testDepends . system . contains (pkg "z3")) True)
-  , ("sdr", over (metaSection . platforms) (Set.filter (\(Platform arch _) -> arch == X86_64))) -- https://github.com/adamwalker/sdr/issues/2
+  , ("sdr", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "x86_64")))) -- https://github.com/adamwalker/sdr/issues/2
   , ("shake-language-c", set doCheck False) -- https://github.com/samplecount/shake-language-c/issues/26
   , ("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)
@@ -175,12 +174,10 @@
   , ("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)))
-  , ("webkitgtk3", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36
-  , ("webkitgtk3-javascriptcore", webkitgtk24xHook)   -- https://github.com/haskell-gi/haskell-gi/issues/36
+  , ("udev", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "linux"))))
   , ("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)))
+  , ("Win32", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "windows"))))
+  , ("Win32-shortcut", set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "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","pkgs.xorg.libXScrnSaver"])))
@@ -351,15 +348,11 @@
 hfseventsOverrides :: Derivation -> Derivation
 hfseventsOverrides
   = set isLibrary True
-  . over (metaSection . platforms) (Set.filter (\(Platform _ os) -> os == OSX))
+  . set (metaSection . platforms) (Just $ Set.singleton (NixpkgsPlatformGroup (ident # "darwin")))
   . set (libraryDepends . tool . contains (bind "pkgs.darwin.apple_sdk.frameworks.CoreServices")) True
   . set (libraryDepends . system . contains (bind "pkgs.darwin.apple_sdk.frameworks.Cocoa")) True
   . 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-gtk3")) True
-                 . over (libraryDepends . pkgconfig) (Set.filter (\b -> view localName b /= "webkitgtk24x-gtk3"))
-
 opencvOverrides :: Derivation -> Derivation
 opencvOverrides = set phaseOverrides "hardeningDisable = [ \"bindnow\" ];"
                 . over (libraryDepends . pkgconfig) (replace (pkg "opencv") (pkg "opencv3"))
@@ -409,7 +402,7 @@
 bustleOverrides = set (libraryDepends . pkgconfig . contains "system-glib = pkgs.glib") True
                 . set (executableDepends . pkgconfig . contains "gio-unix = null") False
                 . set (metaSection . license) (Known "lib.licenses.lgpl21Plus")
-                . set (metaSection . hydraPlatforms) allKnownPlatforms
+                . set (metaSection . hydraPlatforms) Nothing
 
 nullBinding :: Identifier -> Binding
 nullBinding name = binding # (name, path # [ident # "null"])
diff --git a/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs b/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs
--- a/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs
+++ b/src/Distribution/Nixpkgs/Haskell/OrphanInstances.hs
@@ -1,4 +1,5 @@
 {-# OPTIONS_GHC -fno-warn-orphans #-}
+{-# LANGUAGE OverloadedStrings #-}
 
 module Distribution.Nixpkgs.Haskell.OrphanInstances ( ) where
 
@@ -8,6 +9,7 @@
 import qualified Data.Text as T
 import Data.Yaml
 import Distribution.Compiler
+import Distribution.Nixpkgs.Meta
 import Distribution.Package
 import Distribution.Parsec
 import Distribution.System
@@ -35,17 +37,13 @@
 instance IsString CompilerId where
   fromString = text2isString "CompilerId"
 
-instance IsString Platform where
-  fromString "i686-linux" = Platform I386 Linux
-  fromString "x86_64-linux" = Platform X86_64 Linux
-  fromString "x86_64-darwin" = Platform X86_64 OSX
-  fromString "aarch64-linux" = Platform AArch64 Linux
-  fromString "armv7l-linux" = Platform (OtherArch "armv7l") Linux
-  fromString s = error ("fromString: " ++ show s ++ " is not a valid platform")
-
-instance FromJSON Platform where
-  parseJSON (String s) = pure (fromString (T.unpack s))
-  parseJSON s = fail ("parseJSON: " ++ show s ++ " is not a valid platform")
+instance FromJSON NixpkgsPlatform where
+  parseJSON (String s) =
+    case nixpkgsPlatformFromString (T.unpack s) of
+      Just p -> pure p
+      Nothing -> fail ("parseJSON: " ++ show s ++ " is not a valid NixpkgsPlatform")
+  parseJSON s =
+    fail ("parseJSON: expected String for NixpkgsPlatform, but got " ++ show s)
 
 instance FromJSON PackageName where
   parseJSON (String s) = return (fromString (T.unpack s))
diff --git a/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs b/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
--- a/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
+++ b/src/Distribution/Nixpkgs/Haskell/PackageSourceSpec.hs
@@ -1,3 +1,4 @@
+{-# LANGUAGE NamedFieldPuns #-}
 module Distribution.Nixpkgs.Haskell.PackageSourceSpec
   ( HpackUse(..), Package(..), getPackage, getPackage', loadHackageDB, sourceFromHackage
   ) where
@@ -48,7 +49,7 @@
 
 getPackage :: HpackUse
            -- ^ the way hpack should be used.
-           -> Bool
+           -> FetchSubmodules
            -- ^ Whether to fetch submodules if fetching from git
            -> Maybe FilePath
            -- ^ The path to the Hackage database.
@@ -61,18 +62,30 @@
 
 getPackage' :: HpackUse
             -- ^ the way hpack should be used.
-            -> Bool
+            -> FetchSubmodules
             -- ^ Whether to fetch submodules if fetching from git
             -> IO DB.HackageDB
             -> Source
             -> IO Package
 getPackage' optHpack optSubmodules hackageDB source = do
-  (derivSource, ranHpack, pkgDesc) <- fetchOrFromDB optHpack optSubmodules hackageDB source
-  (\s -> Package s ranHpack pkgDesc) <$> maybe (sourceFromHackage (sourceHash source) (showPackageIdentifier pkgDesc) $ sourceCabalDir source) return derivSource
+  (derivSource, pkgRanHpack, pkgCabal) <- fetchOrFromDB optHpack optSubmodules hackageDB source
+  pkgSource <-
+    case derivSource of
+      Nothing ->
+        sourceFromHackage
+          (sourceHash source)
+          (showPackageIdentifier pkgCabal)
+          (sourceCabalDir source)
+      Just derivSource' -> pure derivSource'
+  pure Package {
+    pkgSource,
+    pkgRanHpack,
+    pkgCabal
+  }
 
 fetchOrFromDB :: HpackUse
               -- ^ the way hpack should be used
-              -> Bool
+              -> FetchSubmodules
               -- ^ Whether to fetch submodules if fetching from git
               -> IO DB.HackageDB
               -> Source
@@ -94,7 +107,9 @@
               -- ^ If we have hackage-snapshot time.
               -> IO DB.HackageDB
 loadHackageDB optHackageDB optHackageSnapshot = do
-  dbPath <- maybe DB.hackageTarball return optHackageDB
+  dbPath <- case optHackageDB of
+    Nothing -> DB.hackageTarball
+    Just hackageDb -> return hackageDb
   DB.readTarball optHackageSnapshot dbPath
 
 fromDB :: IO DB.HackageDB
@@ -102,7 +117,9 @@
        -> IO (Maybe DerivationSource, Cabal.GenericPackageDescription)
 fromDB hackageDBIO pkg = do
   hackageDB <- hackageDBIO
-  vd <- maybe unknownPackageError return (DB.lookup name hackageDB >>= lookupVersion)
+  vd <- case DB.lookup name hackageDB >>= lookupVersion of
+    Nothing -> unknownPackageError
+    Just versionData -> pure versionData
   let ds = case DB.tarballSha256 vd of
              Nothing -> Nothing
              Just hash -> Just (urlDerivationSource url hash)
@@ -160,7 +177,16 @@
       seq (length hash) $
       urlDerivationSource url hash <$ writeFile cacheFile hash
     UnknownHash -> do
-      maybeHash <- runMaybeT (derivHash . fst <$> fetchWith (False, "url", Nothing, []) (Source url "" UnknownHash cabalDir))
+      maybeHash <- runMaybeT
+        $ derivHash . fst
+        <$> fetchWith
+              (False, DerivKindUrl DontUnpackArchive)
+              (Source {
+                sourceUrl = url,
+                sourceRevision = "",
+                sourceHash = UnknownHash,
+                sourceCabalDir = cabalDir
+              })
       case maybeHash of
         Just hash ->
           seq (length hash) $
@@ -197,7 +223,7 @@
 cabalFromDirectory ForceHpack dir = hpackDirectory dir
 cabalFromDirectory NoHpack dir = onlyCabalFromDirectory dir "*** No .cabal file was found. Exiting."
 cabalFromDirectory PackageYamlHpack dir = do
-  useHpack <- liftIO $ doesFileExist (dir </> "package.yaml")
+  useHpack <- liftIO $ shouldUseHpack dir
   if useHpack
     then do
       liftIO $ hPutStrLn stderr "*** found package.yaml. Using hpack..."
@@ -206,11 +232,29 @@
 
 onlyCabalFromDirectory :: FilePath -> String -> MaybeT IO (Bool, Cabal.GenericPackageDescription)
 onlyCabalFromDirectory dir errMsg = do
-  cabals <- liftIO $ getDirectoryContents dir >>= filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`)
+  cabals <- liftIO $ findCabalFiles dir
   case cabals of
     [] -> liftIO $ fail errMsg
     [cabalFile] -> (,) False <$> cabalFromFile True cabalFile
     _ -> liftIO $ fail ("*** found more than one cabal file (" ++ show cabals ++ "). Exiting.")
+
+-- | Returns a list of files ending with the @.cabal@ suffix.
+findCabalFiles :: FilePath -> IO [FilePath]
+findCabalFiles dir = do
+  contents <- getDirectoryContents dir
+  filterM doesFileExist . map (dir </>) . filter (".cabal" `isSuffixOf`) $ contents
+
+-- | This function returns 'True' if a @package.yaml@ is present and there
+-- are no @.cabal@ files in the directory.
+shouldUseHpack :: FilePath -> IO Bool
+shouldUseHpack dir = do
+  hpackExists <- doesFileExist (dir </> "package.yaml")
+  if hpackExists
+    then do
+      cabalFiles <- findCabalFiles dir
+      pure $ null cabalFiles
+    else
+      pure False
 
 handleIO :: (Exception.IOException -> IO a) -> IO a -> IO a
 handleIO = Exception.handle
diff --git a/src/Distribution/Nixpkgs/Haskell/Platform.hs b/src/Distribution/Nixpkgs/Haskell/Platform.hs
new file mode 100644
--- /dev/null
+++ b/src/Distribution/Nixpkgs/Haskell/Platform.hs
@@ -0,0 +1,123 @@
+{-# LANGUAGE LambdaCase #-}
+{-|
+Description: Parse platform strings used by nixpkgs into Cabal's 'Platform'
+
+This module defines conversions from the (autoconf-derived) platform strings
+nixpkgs uses into Cabal's 'Platform' type. This is intended to facilitate later
+evaluation of @.cabal@ files. For this conversion Cabal's 'Permissive'
+heuristics are used as well as a logic equivalent to the @GHC_CONVERT_*@ macros
+from GHC's configure script.
+
+Since the process is inherently lossy because Cabal ignores certain factors like
+endianness, conversion from 'Platform' to nixpkgs' platform strings. For this
+usecase, try "Distribution.Nixpkgs.Meta" from @distribution-nixpkgs@.
+-}
+module Distribution.Nixpkgs.Haskell.Platform
+  ( parsePlatformLenient
+  , parsePlatformFromSystemLenient
+  ) where
+
+import Data.List ( isPrefixOf, intercalate )
+import Data.List.Split ( splitOn )
+import Data.Maybe ( fromMaybe, listToMaybe )
+import Distribution.System
+
+-- | Replicate the normalization performed by GHC_CONVERT_CPU in GHC's aclocal.m4
+-- since the output of that is what Cabal parses.
+ghcConvertArch :: String -> String
+ghcConvertArch arch = case arch of
+  "i486"  -> "i386"
+  "i586"  -> "i386"
+  "i686"  -> "i386"
+  "amd64" -> "x86_64"
+  _ -> fromMaybe arch $ listToMaybe
+    [prefix | prefix <- archPrefixes, prefix `isPrefixOf` arch]
+  where archPrefixes =
+          [ "aarch64", "alpha", "arm", "hppa1_1", "hppa", "m68k", "mipseb"
+          , "mipsel", "mips", "powerpc64le", "powerpc64", "powerpc", "s390x"
+          , "sparc64", "sparc"
+          ]
+
+-- | Replicate the normalization performed by GHC_CONVERT_OS in GHC's aclocal.m4
+-- since the output of that is what Cabal parses.
+ghcConvertOS :: String -> String
+ghcConvertOS os = case os of
+  "watchos"       -> "ios"
+  "tvos"          -> "ios"
+  "linux-android" -> "linux-android"
+  "linux-androideabi" -> "linux-androideabi"
+  _ | "linux-" `isPrefixOf` os -> "linux"
+  _ -> fromMaybe os $ listToMaybe
+    [prefix | prefix <- osPrefixes, prefix `isPrefixOf` os]
+  where osPrefixes =
+          [ "gnu", "openbsd", "aix", "darwin", "solaris2", "freebsd", "nto-qnx"]
+
+parseArch :: String -> Arch
+parseArch = classifyArch Permissive . ghcConvertArch
+
+parseOS :: String -> OS
+parseOS = classifyOS Permissive . ghcConvertOS
+
+parsePlatformParts :: [String] -> Maybe Platform
+parsePlatformParts = \case
+  [arch, os] ->
+    Just $ Platform (parseArch arch) (parseOS os)
+  (arch : _ : osParts) ->
+    Just $ Platform (parseArch arch) $ parseOS $ intercalate "-" osParts
+  _ -> Nothing
+
+-- | Convert a platform string of two or three(-ish) components to 'Platform'.
+--
+--   For this, the following logic is utilized:
+--
+--   - If the string has one dash, the form @cpu-os@ is assumed where @os@ may
+--     only have a single component. The @vendor@ part is ignored.
+--
+--   - Otherwise @cpu-vendor-os@ is assumed where @os@ may have any number of
+--     components separated by dashes to accomodate its two component
+--     @kernel-system@ form.
+--
+--   __Note:__ This behavior is different from nixpkgs' @lib.systems.elaborate@:
+--   Because we have no knowledge of the legal contents of the different parts,
+--   we only decide how to parse it based on what form the string has. This can
+--   give different results compared to autoconf or nixpkgs. It will also never
+--   reject an invalid platform string that has a valid form.
+--
+--   >>> parsePlatformLenient "x86_64-unknown-linux"
+--   Just (Platform X86_64 Linux)
+--   >>> parsePlatformLenient "x86_64-pc-linux-gnu"
+--   Just (Platform X86_64 Linux)
+--   >>> parsePlatformLenient "x86_64-linux"
+--   Just (Platform X86_64 Linux)
+--
+--   __Note__ also that this conversion sometimes looses information nixpkgs
+--   would retain:
+--
+--   >>> parsePlatformLenient "powerpc64-unknown-linux"
+--   Just (Platform PPC64 Linux)
+--   >>> parsePlatformLenient "powerpc64le-unknown-linux"
+--   Just (Platform PPC64 Linux)
+parsePlatformLenient :: String -> Maybe Platform
+parsePlatformLenient = parsePlatformParts . splitOn "-"
+
+-- | Convert a Nix style system tuple into a Cabal 'Platform'. The tuple is
+--   assumed to be of the form @cpu-os@, any extra components are assumed to be
+--   part of @os@ to accomodate its @kernel-system@ form.
+--
+--   The same caveats about validation and lossiness apply as for
+--   'parsePlatformLenient'.
+--
+--   >>> parsePlatformFromSystemLenient "x86_64-linux"
+--   Just (Platform X86_64 Linux)
+--   >>> parsePlatformFromSystemLenient "x86_64-linux-musl"
+--   Just (Platform X86_64 Linux)
+--   >>> parsePlatformFromSystemLenient "i686-netbsd"
+--   Just (Platform I386 NetBSD)
+parsePlatformFromSystemLenient :: String -> Maybe Platform
+parsePlatformFromSystemLenient s =
+  case break (== '-') s of
+    (arch, '-':os) ->
+      if null arch || null os
+      then Nothing
+      else parsePlatformParts [arch, os]
+    _ -> Nothing
diff --git a/test/Main.hs b/test/Main.hs
--- a/test/Main.hs
+++ b/test/Main.hs
@@ -1,4 +1,5 @@
 {-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE LambdaCase #-}
 
 module Main ( main ) where
 
@@ -31,7 +32,9 @@
   --       depend on the system environment: https://github.com/NixOS/cabal2nix/issues/333.
   --
   -- TODO: Run this test without $HOME defined to ensure that we don't need that variable.
-  cabal2nix <- findExecutable "cabal2nix" >>= maybe (fail "cannot find 'cabal2nix' in $PATH") return
+  cabal2nix <- findExecutable "cabal2nix" >>= \case
+    Nothing -> fail "cannot find 'cabal2nix' in $PATH"
+    Just exe -> pure exe
   testCases <- listDirectoryFilesBySuffix ".cabal" "test/golden-test-cases"
   defaultMain $ testGroup "regression-tests"
     [ testGroup "cabal2nix library" (map testLibrary testCases)
@@ -53,7 +56,7 @@
                          []
                          gpd
                        & src .~ DerivationSource
-                                  { derivKind     = "url"
+                                  { derivKind     = Just (DerivKindUrl DontUnpackArchive )
                                   , derivUrl      = "mirror://hackage/foo.tar.gz"
                                   , derivRevision = ""
                                   , derivHash     = "deadbeef"
diff --git a/test/golden-test-cases/HTF.nix.golden b/test/golden-test-cases/HTF.nix.golden
--- a/test/golden-test-cases/HTF.nix.golden
+++ b/test/golden-test-cases/HTF.nix.golden
@@ -28,4 +28,5 @@
   homepage = "https://github.com/skogsbaer/HTF/";
   description = "The Haskell Test Framework";
   license = "LGPL";
+  mainProgram = "htfpp";
 }
diff --git a/test/golden-test-cases/ReadArgs.nix.golden b/test/golden-test-cases/ReadArgs.nix.golden
--- a/test/golden-test-cases/ReadArgs.nix.golden
+++ b/test/golden-test-cases/ReadArgs.nix.golden
@@ -11,4 +11,5 @@
   homepage = "http://github.com/rampion/ReadArgs";
   description = "Simple command line argument parsing";
   license = lib.licenses.bsd3;
+  mainProgram = "ReadArgsEx";
 }
diff --git a/test/golden-test-cases/aeson-pretty.nix.golden b/test/golden-test-cases/aeson-pretty.nix.golden
--- a/test/golden-test-cases/aeson-pretty.nix.golden
+++ b/test/golden-test-cases/aeson-pretty.nix.golden
@@ -17,4 +17,5 @@
   homepage = "http://github.com/informatikr/aeson-pretty";
   description = "JSON pretty-printing library and command-line tool";
   license = lib.licenses.bsd3;
+  mainProgram = "aeson-pretty";
 }
diff --git a/test/golden-test-cases/apply-refact.nix.golden b/test/golden-test-cases/apply-refact.nix.golden
--- a/test/golden-test-cases/apply-refact.nix.golden
+++ b/test/golden-test-cases/apply-refact.nix.golden
@@ -26,4 +26,5 @@
   ];
   description = "Perform refactorings specified by the refact library";
   license = lib.licenses.bsd3;
+  mainProgram = "refactor";
 }
diff --git a/test/golden-test-cases/benchpress.nix.golden b/test/golden-test-cases/benchpress.nix.golden
--- a/test/golden-test-cases/benchpress.nix.golden
+++ b/test/golden-test-cases/benchpress.nix.golden
@@ -10,4 +10,5 @@
   homepage = "https://github.com/WillSewell/benchpress";
   description = "Micro-benchmarking with detailed statistics";
   license = lib.licenses.bsd3;
+  mainProgram = "example";
 }
diff --git a/test/golden-test-cases/blosum.nix.golden b/test/golden-test-cases/blosum.nix.golden
--- a/test/golden-test-cases/blosum.nix.golden
+++ b/test/golden-test-cases/blosum.nix.golden
@@ -17,4 +17,5 @@
   homepage = "http://github.com/GregorySchwartz/blosum#readme";
   description = "BLOSUM generator";
   license = lib.licenses.gpl2Only;
+  mainProgram = "blosum";
 }
diff --git a/test/golden-test-cases/brittany.nix.golden b/test/golden-test-cases/brittany.nix.golden
--- a/test/golden-test-cases/brittany.nix.golden
+++ b/test/golden-test-cases/brittany.nix.golden
@@ -35,4 +35,5 @@
   homepage = "https://github.com/lspitzner/brittany/";
   description = "Haskell source code formatter";
   license = lib.licenses.agpl3Only;
+  mainProgram = "brittany";
 }
diff --git a/test/golden-test-cases/cheapskate.nix.golden b/test/golden-test-cases/cheapskate.nix.golden
--- a/test/golden-test-cases/cheapskate.nix.golden
+++ b/test/golden-test-cases/cheapskate.nix.golden
@@ -16,4 +16,5 @@
   homepage = "http://github.com/jgm/cheapskate";
   description = "Experimental markdown processor";
   license = lib.licenses.bsd3;
+  mainProgram = "cheapskate";
 }
diff --git a/test/golden-test-cases/colorize-haskell.nix.golden b/test/golden-test-cases/colorize-haskell.nix.golden
--- a/test/golden-test-cases/colorize-haskell.nix.golden
+++ b/test/golden-test-cases/colorize-haskell.nix.golden
@@ -10,4 +10,5 @@
   homepage = "http://github.com/yav/colorize-haskell";
   description = "Highligt Haskell source";
   license = lib.licenses.bsd3;
+  mainProgram = "hscolor";
 }
diff --git a/test/golden-test-cases/criterion.nix.golden b/test/golden-test-cases/criterion.nix.golden
--- a/test/golden-test-cases/criterion.nix.golden
+++ b/test/golden-test-cases/criterion.nix.golden
@@ -28,4 +28,5 @@
   homepage = "http://www.serpentine.com/criterion";
   description = "Robust, reliable performance measurement and analysis";
   license = lib.licenses.bsd3;
+  mainProgram = "criterion-report";
 }
diff --git a/test/golden-test-cases/data-msgpack.nix.golden b/test/golden-test-cases/data-msgpack.nix.golden
--- a/test/golden-test-cases/data-msgpack.nix.golden
+++ b/test/golden-test-cases/data-msgpack.nix.golden
@@ -23,4 +23,5 @@
   homepage = "http://msgpack.org/";
   description = "A Haskell implementation of MessagePack";
   license = lib.licenses.bsd3;
+  mainProgram = "msgpack-parser";
 }
diff --git a/test/golden-test-cases/dhall-bash.nix.golden b/test/golden-test-cases/dhall-bash.nix.golden
--- a/test/golden-test-cases/dhall-bash.nix.golden
+++ b/test/golden-test-cases/dhall-bash.nix.golden
@@ -17,4 +17,5 @@
   ];
   description = "Compile Dhall to Bash";
   license = lib.licenses.bsd3;
+  mainProgram = "dhall-to-bash";
 }
diff --git a/test/golden-test-cases/dotenv.nix.golden b/test/golden-test-cases/dotenv.nix.golden
--- a/test/golden-test-cases/dotenv.nix.golden
+++ b/test/golden-test-cases/dotenv.nix.golden
@@ -24,4 +24,5 @@
   homepage = "https://github.com/stackbuilders/dotenv-hs";
   description = "Loads environment variables from dotenv files";
   license = lib.licenses.mit;
+  mainProgram = "dotenv";
 }
diff --git a/test/golden-test-cases/ede.nix.golden b/test/golden-test-cases/ede.nix.golden
--- a/test/golden-test-cases/ede.nix.golden
+++ b/test/golden-test-cases/ede.nix.golden
@@ -21,5 +21,4 @@
   homepage = "http://github.com/brendanhay/ede";
   description = "Templating language with similar syntax and features to Liquid or Jinja2";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/file-modules.nix.golden b/test/golden-test-cases/file-modules.nix.golden
--- a/test/golden-test-cases/file-modules.nix.golden
+++ b/test/golden-test-cases/file-modules.nix.golden
@@ -18,4 +18,5 @@
   homepage = "https://github.com/yamadapc/stack-run-auto";
   description = "Takes a Haskell source-code file and outputs its modules";
   license = lib.licenses.mit;
+  mainProgram = "file-modules";
 }
diff --git a/test/golden-test-cases/ghcid.nix.golden b/test/golden-test-cases/ghcid.nix.golden
--- a/test/golden-test-cases/ghcid.nix.golden
+++ b/test/golden-test-cases/ghcid.nix.golden
@@ -22,4 +22,5 @@
   homepage = "https://github.com/ndmitchell/ghcid#readme";
   description = "GHCi based bare bones IDE";
   license = lib.licenses.bsd3;
+  mainProgram = "ghcid";
 }
diff --git a/test/golden-test-cases/gogol-adexchange-buyer.nix.golden b/test/golden-test-cases/gogol-adexchange-buyer.nix.golden
--- a/test/golden-test-cases/gogol-adexchange-buyer.nix.golden
+++ b/test/golden-test-cases/gogol-adexchange-buyer.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Ad Exchange Buyer SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-admin-emailmigration.nix.golden b/test/golden-test-cases/gogol-admin-emailmigration.nix.golden
--- a/test/golden-test-cases/gogol-admin-emailmigration.nix.golden
+++ b/test/golden-test-cases/gogol-admin-emailmigration.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Email Migration API v2 SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-affiliates.nix.golden b/test/golden-test-cases/gogol-affiliates.nix.golden
--- a/test/golden-test-cases/gogol-affiliates.nix.golden
+++ b/test/golden-test-cases/gogol-affiliates.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Affiliate Network SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-apps-tasks.nix.golden b/test/golden-test-cases/gogol-apps-tasks.nix.golden
--- a/test/golden-test-cases/gogol-apps-tasks.nix.golden
+++ b/test/golden-test-cases/gogol-apps-tasks.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Tasks SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-appstate.nix.golden b/test/golden-test-cases/gogol-appstate.nix.golden
--- a/test/golden-test-cases/gogol-appstate.nix.golden
+++ b/test/golden-test-cases/gogol-appstate.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google App State SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-blogger.nix.golden b/test/golden-test-cases/gogol-blogger.nix.golden
--- a/test/golden-test-cases/gogol-blogger.nix.golden
+++ b/test/golden-test-cases/gogol-blogger.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Blogger SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-datastore.nix.golden b/test/golden-test-cases/gogol-datastore.nix.golden
--- a/test/golden-test-cases/gogol-datastore.nix.golden
+++ b/test/golden-test-cases/gogol-datastore.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Cloud Datastore SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-dfareporting.nix.golden b/test/golden-test-cases/gogol-dfareporting.nix.golden
--- a/test/golden-test-cases/gogol-dfareporting.nix.golden
+++ b/test/golden-test-cases/gogol-dfareporting.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google DCM/DFA Reporting And Trafficking SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-firebase-rules.nix.golden b/test/golden-test-cases/gogol-firebase-rules.nix.golden
--- a/test/golden-test-cases/gogol-firebase-rules.nix.golden
+++ b/test/golden-test-cases/gogol-firebase-rules.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Firebase Rules SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-gmail.nix.golden b/test/golden-test-cases/gogol-gmail.nix.golden
--- a/test/golden-test-cases/gogol-gmail.nix.golden
+++ b/test/golden-test-cases/gogol-gmail.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Gmail SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-kgsearch.nix.golden b/test/golden-test-cases/gogol-kgsearch.nix.golden
--- a/test/golden-test-cases/gogol-kgsearch.nix.golden
+++ b/test/golden-test-cases/gogol-kgsearch.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Knowledge Graph Search SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-maps-engine.nix.golden b/test/golden-test-cases/gogol-maps-engine.nix.golden
--- a/test/golden-test-cases/gogol-maps-engine.nix.golden
+++ b/test/golden-test-cases/gogol-maps-engine.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Maps Engine SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-plus.nix.golden b/test/golden-test-cases/gogol-plus.nix.golden
--- a/test/golden-test-cases/gogol-plus.nix.golden
+++ b/test/golden-test-cases/gogol-plus.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google + SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-resourceviews.nix.golden b/test/golden-test-cases/gogol-resourceviews.nix.golden
--- a/test/golden-test-cases/gogol-resourceviews.nix.golden
+++ b/test/golden-test-cases/gogol-resourceviews.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Compute Engine Instance Groups SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-translate.nix.golden b/test/golden-test-cases/gogol-translate.nix.golden
--- a/test/golden-test-cases/gogol-translate.nix.golden
+++ b/test/golden-test-cases/gogol-translate.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Translate SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-webmaster-tools.nix.golden b/test/golden-test-cases/gogol-webmaster-tools.nix.golden
--- a/test/golden-test-cases/gogol-webmaster-tools.nix.golden
+++ b/test/golden-test-cases/gogol-webmaster-tools.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google Search Console SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/gogol-youtube.nix.golden b/test/golden-test-cases/gogol-youtube.nix.golden
--- a/test/golden-test-cases/gogol-youtube.nix.golden
+++ b/test/golden-test-cases/gogol-youtube.nix.golden
@@ -7,5 +7,4 @@
   homepage = "https://github.com/brendanhay/gogol";
   description = "Google YouTube Data SDK";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/hakyll.nix.golden b/test/golden-test-cases/hakyll.nix.golden
--- a/test/golden-test-cases/hakyll.nix.golden
+++ b/test/golden-test-cases/hakyll.nix.golden
@@ -39,4 +39,5 @@
   homepage = "http://jaspervdj.be/hakyll";
   description = "A static website compiler library";
   license = lib.licenses.bsd3;
+  mainProgram = "hakyll-init";
 }
diff --git a/test/golden-test-cases/happy.nix.golden b/test/golden-test-cases/happy.nix.golden
--- a/test/golden-test-cases/happy.nix.golden
+++ b/test/golden-test-cases/happy.nix.golden
@@ -13,4 +13,5 @@
   homepage = "https://www.haskell.org/happy/";
   description = "Happy is a parser generator for Haskell";
   license = lib.licenses.bsd2;
+  mainProgram = "happy";
 }
diff --git a/test/golden-test-cases/haskell-tools-debug.nix.golden b/test/golden-test-cases/haskell-tools-debug.nix.golden
--- a/test/golden-test-cases/haskell-tools-debug.nix.golden
+++ b/test/golden-test-cases/haskell-tools-debug.nix.golden
@@ -19,4 +19,5 @@
   homepage = "https://github.com/haskell-tools/haskell-tools";
   description = "Debugging Tools for Haskell-tools";
   license = lib.licenses.bsd3;
+  mainProgram = "ht-debug";
 }
diff --git a/test/golden-test-cases/hoogle.nix.golden b/test/golden-test-cases/hoogle.nix.golden
--- a/test/golden-test-cases/hoogle.nix.golden
+++ b/test/golden-test-cases/hoogle.nix.golden
@@ -27,4 +27,5 @@
   homepage = "http://hoogle.haskell.org/";
   description = "Haskell API Search";
   license = lib.licenses.bsd3;
+  mainProgram = "hoogle";
 }
diff --git a/test/golden-test-cases/hsinstall.nix.golden b/test/golden-test-cases/hsinstall.nix.golden
--- a/test/golden-test-cases/hsinstall.nix.golden
+++ b/test/golden-test-cases/hsinstall.nix.golden
@@ -10,4 +10,5 @@
   executableHaskellDepends = [ base directory filepath ];
   description = "Install Haskell software";
   license = lib.licenses.isc;
+  mainProgram = "an-app";
 }
diff --git a/test/golden-test-cases/hxt-expat.nix.golden b/test/golden-test-cases/hxt-expat.nix.golden
--- a/test/golden-test-cases/hxt-expat.nix.golden
+++ b/test/golden-test-cases/hxt-expat.nix.golden
@@ -7,5 +7,4 @@
   homepage = "http://www.fh-wedel.de/~si/HXmlToolbox/index.html";
   description = "Expat parser for HXT";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/hxt-tagsoup.nix.golden b/test/golden-test-cases/hxt-tagsoup.nix.golden
--- a/test/golden-test-cases/hxt-tagsoup.nix.golden
+++ b/test/golden-test-cases/hxt-tagsoup.nix.golden
@@ -11,5 +11,4 @@
   homepage = "https://github.com/UweSchmidt/hxt";
   description = "TagSoup parser for HXT";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/intero.nix.golden b/test/golden-test-cases/intero.nix.golden
--- a/test/golden-test-cases/intero.nix.golden
+++ b/test/golden-test-cases/intero.nix.golden
@@ -21,4 +21,5 @@
   homepage = "https://github.com/commercialhaskell/intero";
   description = "Complete interactive development program for Haskell";
   license = lib.licenses.bsd3;
+  mainProgram = "intero";
 }
diff --git a/test/golden-test-cases/jose.nix.golden b/test/golden-test-cases/jose.nix.golden
--- a/test/golden-test-cases/jose.nix.golden
+++ b/test/golden-test-cases/jose.nix.golden
@@ -28,4 +28,5 @@
   homepage = "https://github.com/frasertweedale/hs-jose";
   description = "Javascript Object Signing and Encryption and JSON Web Token library";
   license = lib.licenses.asl20;
+  mainProgram = "example";
 }
diff --git a/test/golden-test-cases/katydid.nix.golden b/test/golden-test-cases/katydid.nix.golden
--- a/test/golden-test-cases/katydid.nix.golden
+++ b/test/golden-test-cases/katydid.nix.golden
@@ -18,4 +18,5 @@
   homepage = "https://github.com/katydid/katydid-haskell";
   description = "A haskell implementation of Katydid";
   license = lib.licenses.bsd3;
+  mainProgram = "katydid-exe";
 }
diff --git a/test/golden-test-cases/lazy-csv.nix.golden b/test/golden-test-cases/lazy-csv.nix.golden
--- a/test/golden-test-cases/lazy-csv.nix.golden
+++ b/test/golden-test-cases/lazy-csv.nix.golden
@@ -10,4 +10,5 @@
   homepage = "http://code.haskell.org/lazy-csv";
   description = "Efficient lazy parsers for CSV (comma-separated values)";
   license = lib.licenses.bsd3;
+  mainProgram = "csvSelect";
 }
diff --git a/test/golden-test-cases/mole.nix.golden b/test/golden-test-cases/mole.nix.golden
--- a/test/golden-test-cases/mole.nix.golden
+++ b/test/golden-test-cases/mole.nix.golden
@@ -23,4 +23,5 @@
   ];
   description = "A glorified string replacement tool";
   license = lib.licenses.mit;
+  mainProgram = "mole";
 }
diff --git a/test/golden-test-cases/nvim-hs.nix.golden b/test/golden-test-cases/nvim-hs.nix.golden
--- a/test/golden-test-cases/nvim-hs.nix.golden
+++ b/test/golden-test-cases/nvim-hs.nix.golden
@@ -36,4 +36,5 @@
   homepage = "https://github.com/neovimhaskell/nvim-hs";
   description = "Haskell plugin backend for neovim";
   license = lib.licenses.asl20;
+  mainProgram = "nvim-hs";
 }
diff --git a/test/golden-test-cases/openpgp-asciiarmor.nix.golden b/test/golden-test-cases/openpgp-asciiarmor.nix.golden
--- a/test/golden-test-cases/openpgp-asciiarmor.nix.golden
+++ b/test/golden-test-cases/openpgp-asciiarmor.nix.golden
@@ -15,5 +15,4 @@
   homepage = "http://floss.scru.org/openpgp-asciiarmor";
   description = "OpenPGP (RFC4880) ASCII Armor codec";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/pager.nix.golden b/test/golden-test-cases/pager.nix.golden
--- a/test/golden-test-cases/pager.nix.golden
+++ b/test/golden-test-cases/pager.nix.golden
@@ -16,4 +16,5 @@
   homepage = "https://github.com/pharpend/pager";
   description = "Open up a pager, like 'less' or 'more'";
   license = lib.licenses.bsd2;
+  mainProgram = "hs-pager-test-pager";
 }
diff --git a/test/golden-test-cases/pandoc.cabal b/test/golden-test-cases/pandoc.cabal
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/pandoc.cabal
@@ -0,0 +1,891 @@
+cabal-version:   2.4
+name:            pandoc
+version:         2.18
+build-type:      Simple
+license:         GPL-2.0-or-later
+license-file:    COPYING.md
+copyright:       (c) 2006-2022 John MacFarlane
+author:          John MacFarlane <jgm@berkeley.edu>
+maintainer:      John MacFarlane <jgm@berkeley.edu>
+bug-reports:     https://github.com/jgm/pandoc/issues
+stability:       alpha
+homepage:        https://pandoc.org
+category:        Text
+tested-with:     GHC == 8.6.5, GHC == 8.8.4, GHC == 8.10.7, GHC == 9.0.1,
+                 GHC == 9.2.2
+synopsis:        Conversion between markup formats
+description:     Pandoc is a Haskell library for converting from one markup
+                 format to another, and a command-line tool that uses
+                 this library. The formats it can handle include
+                 .
+                 - light markup formats (many variants of Markdown,
+                   reStructuredText, AsciiDoc, Org-mode, Muse, Textile,
+                   txt2tags)
+                 - HTML formats (HTML 4 and 5)
+                 - Ebook formats (EPUB v2 and v3, FB2)
+                 - Documentation formats (GNU TexInfo, Haddock)
+                 - Roff formats (man, ms)
+                 - TeX formats (LaTeX, ConTeXt)
+                 - XML formats (DocBook 4 and 5, JATS, TEI Simple, OpenDocument)
+                 - Outline formats (OPML)
+                 - Bibliography formats (BibTeX, BibLaTeX, CSL JSON, CSL YAML)
+                 - Word processor formats (Docx, RTF, ODT)
+                 - Interactive notebook formats (Jupyter notebook ipynb)
+                 - Page layout formats (InDesign ICML)
+                 - Wiki markup formats (MediaWiki, DokuWiki, TikiWiki, TWiki,
+                   Vimwiki, XWiki, ZimWiki, Jira wiki, Creole)
+                 - Slide show formats (LaTeX Beamer, PowerPoint, Slidy,
+                   reveal.js, Slideous, S5, DZSlides)
+                 - Data formats (CSV tables)
+                 - PDF (via external programs such as pdflatex or wkhtmltopdf)
+                 .
+                 Pandoc can convert mathematical content in documents
+                 between TeX, MathML, Word equations, roff eqn, and plain text.
+                 It includes a powerful system for automatic citations
+                 and bibliographies, and it can be customized extensively
+                 using templates, filters, and custom readers and writers
+                 written in Lua.
+data-files:
+                 -- templates
+                 data/templates/styles.html
+                 data/templates/default.html4
+                 data/templates/default.html5
+                 data/templates/default.docbook4
+                 data/templates/default.docbook5
+                 data/templates/default.jats_archiving
+                 data/templates/default.jats_articleauthoring
+                 data/templates/default.jats_publishing
+                 data/templates/default.tei
+                 data/templates/default.opendocument
+                 data/templates/default.icml
+                 data/templates/default.opml
+                 data/templates/default.latex
+                 data/templates/default.bibtex
+                 data/templates/default.biblatex
+                 data/templates/default.context
+                 data/templates/default.texinfo
+                 data/templates/default.jira
+                 data/templates/default.man
+                 data/templates/default.ms
+                 data/templates/default.markdown
+                 data/templates/default.muse
+                 data/templates/default.commonmark
+                 data/templates/default.rst
+                 data/templates/default.plain
+                 data/templates/default.mediawiki
+                 data/templates/default.dokuwiki
+                 data/templates/default.xwiki
+                 data/templates/default.zimwiki
+                 data/templates/default.rtf
+                 data/templates/default.s5
+                 data/templates/default.slidy
+                 data/templates/default.slideous
+                 data/templates/default.revealjs
+                 data/templates/default.dzslides
+                 data/templates/default.asciidoc
+                 data/templates/default.asciidoctor
+                 data/templates/default.haddock
+                 data/templates/default.textile
+                 data/templates/default.org
+                 data/templates/default.epub2
+                 data/templates/default.epub3
+                 data/templates/article.jats_publishing
+                 data/templates/affiliations.jats
+                 data/templates/default.markua
+                 -- translations
+                 data/translations/*.yaml
+                 -- entities
+                 data/docbook-entities.txt
+                 -- source files for reference.docx
+                 data/docx/[Content_Types].xml
+                 data/docx/_rels/.rels
+                 data/docx/docProps/app.xml
+                 data/docx/docProps/core.xml
+                 data/docx/docProps/custom.xml
+                 data/docx/word/document.xml
+                 data/docx/word/fontTable.xml
+                 data/docx/word/comments.xml
+                 data/docx/word/footnotes.xml
+                 data/docx/word/numbering.xml
+                 data/docx/word/settings.xml
+                 data/docx/word/webSettings.xml
+                 data/docx/word/styles.xml
+                 data/docx/word/_rels/document.xml.rels
+                 data/docx/word/_rels/footnotes.xml.rels
+                 data/docx/word/theme/theme1.xml
+                 -- source files for reference.odt
+                 data/odt/mimetype
+                 data/odt/manifest.rdf
+                 data/odt/styles.xml
+                 data/odt/content.xml
+                 data/odt/meta.xml
+                 data/odt/settings.xml
+                 data/odt/Configurations2/accelerator/current.xml
+                 data/odt/Thumbnails/thumbnail.png
+                 data/odt/META-INF/manifest.xml
+                 -- source files for reference.pptx
+                 data/pptx/_rels/.rels
+                 data/pptx/docProps/app.xml
+                 data/pptx/docProps/core.xml
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout1.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout2.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout3.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout4.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout5.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout6.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout7.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout8.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout9.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout10.xml.rels
+                 data/pptx/ppt/slideLayouts/_rels/slideLayout11.xml.rels
+                 data/pptx/ppt/slideLayouts/slideLayout1.xml
+                 data/pptx/ppt/slideLayouts/slideLayout2.xml
+                 data/pptx/ppt/slideLayouts/slideLayout3.xml
+                 data/pptx/ppt/slideLayouts/slideLayout4.xml
+                 data/pptx/ppt/slideLayouts/slideLayout5.xml
+                 data/pptx/ppt/slideLayouts/slideLayout6.xml
+                 data/pptx/ppt/slideLayouts/slideLayout7.xml
+                 data/pptx/ppt/slideLayouts/slideLayout8.xml
+                 data/pptx/ppt/slideLayouts/slideLayout9.xml
+                 data/pptx/ppt/slideLayouts/slideLayout10.xml
+                 data/pptx/ppt/slideLayouts/slideLayout11.xml
+                 data/pptx/ppt/_rels/presentation.xml.rels
+                 data/pptx/ppt/theme/theme1.xml
+                 data/pptx/ppt/presProps.xml
+                 data/pptx/ppt/slides/_rels/slide1.xml.rels
+                 data/pptx/ppt/slides/_rels/slide2.xml.rels
+                 data/pptx/ppt/slides/slide2.xml
+                 data/pptx/ppt/slides/slide1.xml
+                 data/pptx/ppt/slides/_rels/slide3.xml.rels
+                 data/pptx/ppt/slides/_rels/slide4.xml.rels
+                 data/pptx/ppt/slides/slide3.xml
+                 data/pptx/ppt/slides/slide4.xml
+                 data/pptx/ppt/viewProps.xml
+                 data/pptx/ppt/tableStyles.xml
+                 data/pptx/ppt/slideMasters/_rels/slideMaster1.xml.rels
+                 data/pptx/ppt/slideMasters/slideMaster1.xml
+                 data/pptx/ppt/presentation.xml
+                 data/pptx/ppt/notesMasters/_rels/notesMaster1.xml.rels
+                 data/pptx/ppt/notesMasters/notesMaster1.xml
+                 data/pptx/ppt/notesSlides/_rels/notesSlide1.xml.rels
+                 data/pptx/ppt/notesSlides/notesSlide1.xml
+                 data/pptx/ppt/notesSlides/_rels/notesSlide2.xml.rels
+                 data/pptx/ppt/notesSlides/notesSlide2.xml
+                 data/pptx/ppt/theme/theme2.xml
+                 data/pptx/[Content_Types].xml
+                  -- stylesheet for EPUB writer
+                 data/epub.css
+                 -- data for dzslides writer
+                 data/dzslides/template.html
+                 -- default abbreviations file
+                 data/abbreviations
+                 -- sample lua custom writer
+                 data/sample.lua
+                 -- sample lua custom reader
+                 data/creole.lua
+                 -- lua init script
+                 data/init.lua
+                 -- bash completion template
+                 data/bash_completion.tpl
+                 -- citeproc
+                 data/default.csl
+                 citeproc/biblatex-localization/*.lbx.strings
+                 -- documentation
+                 MANUAL.txt, COPYRIGHT
+extra-source-files:
+                 -- documentation
+                 INSTALL.md, AUTHORS.md, README.md,
+                 CONTRIBUTING.md, BUGS, changelog.md,
+                 man/pandoc.1
+                 -- cabal and stack build plans
+                 cabal.project
+                 stack.yaml
+                 -- files needed to build man page
+                 man/manfilter.lua
+                 man/pandoc.1.before
+                 man/pandoc.1.after
+                 -- trypandoc
+                 trypandoc/Makefile
+                 trypandoc/index.html
+                 -- tests
+                 test/bodybg.gif
+                 test/*.native
+                 test/command/*.md
+                 test/command/*.csl
+                 test/command/biblio.bib
+                 test/command/averroes.bib
+                 test/command/A.txt
+                 test/command/B.txt
+                 test/command/C.txt
+                 test/command/D.txt
+                 test/command/three.txt
+                 test/command/01.csv
+                 test/command/chap1/spider.png
+                 test/command/chap2/spider.png
+                 test/command/chap1/text.md
+                 test/command/chap2/text.md
+                 test/command/defaults1.yaml
+                 test/command/defaults2.yaml
+                 test/command/defaults3.yaml
+                 test/command/defaults4.yaml
+                 test/command/defaults5.yaml
+                 test/command/defaults6.yaml
+                 test/command/defaults7.yaml
+                 test/command/defaults8.yaml
+                 test/command/defaults9.yaml
+                 test/command/3533-rst-csv-tables.csv
+                 test/command/3880.txt
+                 test/command/5182.txt
+                 test/command/5700-metadata-file-1.yml
+                 test/command/5700-metadata-file-2.yml
+                 test/command/abbrevs
+                 test/command/SVG_logo-without-xml-declaration.svg
+                 test/command/SVG_logo.svg
+                 test/command/corrupt.svg
+                 test/command/inkscape-cube.svg
+                 test/command/lua-pandoc-state.lua
+                 test/command/sub-file-chapter-1.tex
+                 test/command/sub-file-chapter-2.tex
+                 test/command/bar.tex
+                 test/command/bar-endinput.tex
+                 test/command/yaml-metadata.yaml
+                 test/command/7813-meta.yaml
+                 test/command/3510-subdoc.org
+                 test/command/3510-export.latex
+                 test/command/3510-src.hs
+                 test/command/3971b.tex
+                 test/command/5876.yaml
+                 test/command/5876/metadata/5876.yaml
+                 test/command/5876/metadata/command/5876.yaml
+                 test/command/7861.yaml
+                 test/command/7861/metadata/placeholder
+                 test/docbook-chapter.docbook
+                 test/docbook-reader.docbook
+                 test/docbook-xref.docbook
+                 test/endnotexml-reader.xml
+                 test/html-reader.html
+                 test/opml-reader.opml
+                 test/org-select-tags.org
+                 test/haddock-reader.haddock
+                 test/insert
+                 test/lalune.jpg
+                 test/man-reader.man
+                 test/movie.jpg
+                 test/media/rId25.jpg
+                 test/media/rId26.jpg
+                 test/media/rId27.jpg
+                 test/latex-reader.latex
+                 test/textile-reader.textile
+                 test/markdown-reader-more.txt
+                 test/markdown-citations.txt
+                 test/textile-reader.textile
+                 test/mediawiki-reader.wiki
+                 test/vimwiki-reader.wiki
+                 test/creole-reader.txt
+                 test/rst-reader.rst
+                 test/jats-reader.xml
+                 test/jira-reader.jira
+                 test/s5-basic.html
+                 test/s5-fancy.html
+                 test/s5-fragment.html
+                 test/s5-inserts.html
+                 test/tables.context
+                 test/tables.docbook4
+                 test/tables.docbook5
+                 test/tables.jats_archiving
+                 test/tables.jats_articleauthoring
+                 test/tables.jats_publishing
+                 test/tables.jira
+                 test/tables.dokuwiki
+                 test/tables.zimwiki
+                 test/tables.icml
+                 test/tables.html4
+                 test/tables.html5
+                 test/tables.latex
+                 test/tables.man
+                 test/tables.ms
+                 test/tables.plain
+                 test/tables.markdown
+                 test/tables.markua
+                 test/tables.mediawiki
+                 test/tables.tei
+                 test/tables.textile
+                 test/tables.opendocument
+                 test/tables.org
+                 test/tables.asciidoc
+                 test/tables.asciidoctor
+                 test/tables.haddock
+                 test/tables.texinfo
+                 test/tables.rst
+                 test/tables.rtf
+                 test/tables.txt
+                 test/tables.fb2
+                 test/tables.muse
+                 test/tables.custom
+                 test/tables.xwiki
+                 test/tables/*.html4
+                 test/tables/*.html5
+                 test/tables/*.latex
+                 test/tables/*.native
+                 test/tables/*.jats_archiving
+                 test/testsuite.txt
+                 test/writer.latex
+                 test/writer.context
+                 test/writer.docbook4
+                 test/writer.docbook5
+                 test/writer.jats_archiving
+                 test/writer.jats_articleauthoring
+                 test/writer.jats_publishing
+                 test/writer.jira
+                 test/writer.html4
+                 test/writer.html5
+                 test/writer.man
+                 test/writer.ms
+                 test/writer.markdown
+                 test/writer.markua
+                 test/writer.plain
+                 test/writer.mediawiki
+                 test/writer.textile
+                 test/writer.opendocument
+                 test/writer.org
+                 test/writer.asciidoc
+                 test/writer.asciidoctor
+                 test/writer.haddock
+                 test/writer.rst
+                 test/writer.icml
+                 test/writer.rtf
+                 test/writer.tei
+                 test/writer.texinfo
+                 test/writer.fb2
+                 test/writer.opml
+                 test/writer.dokuwiki
+                 test/writer.zimwiki
+                 test/writer.xwiki
+                 test/writer.muse
+                 test/writer.custom
+                 test/writers-lang-and-dir.latex
+                 test/writers-lang-and-dir.context
+                 test/dokuwiki_inline_formatting.dokuwiki
+                 test/lhs-test.markdown
+                 test/lhs-test.markdown+lhs
+                 test/lhs-test.rst
+                 test/lhs-test.rst+lhs
+                 test/lhs-test.latex
+                 test/lhs-test.latex+lhs
+                 test/lhs-test.html
+                 test/lhs-test.html+lhs
+                 test/lhs-test.fragment.html+lhs
+                 test/pipe-tables.txt
+                 test/dokuwiki_external_images.dokuwiki
+                 test/dokuwiki_multiblock_table.dokuwiki
+                 test/fb2/*.markdown
+                 test/fb2/*.fb2
+                 test/fb2/images-embedded.html
+                 test/fb2/images-embedded.fb2
+                 test/fb2/test-small.png
+                 test/fb2/reader/*.fb2
+                 test/fb2/reader/*.native
+                 test/fb2/test.jpg
+                 test/docx/*.docx
+                 test/docx/golden/*.docx
+                 test/docx/*.native
+                 test/epub/*.epub
+                 test/epub/*.native
+                 test/rtf/*.native
+                 test/rtf/*.rtf
+                 test/pptx/*.pptx
+                 test/pptx/**/*.pptx
+                 test/pptx/**/*.native
+                 test/ipynb/*.native
+                 test/ipynb/*.in.native
+                 test/ipynb/*.out.native
+                 test/ipynb/*.ipynb
+                 test/ipynb/*.out.ipynb
+                 test/ipynb/*.out.html
+                 test/txt2tags.t2t
+                 test/twiki-reader.twiki
+                 test/tikiwiki-reader.tikiwiki
+                 test/odt/odt/*.odt
+                 test/odt/markdown/*.md
+                 test/odt/native/*.native
+                 test/lua/*.lua
+                 test/lua/module/*.lua
+                 test/lua/module/partial.test
+                 test/lua/module/tiny.epub
+source-repository head
+  type:          git
+  location:      git://github.com/jgm/pandoc.git
+
+flag embed_data_files
+  Description:   Embed data files in binary for relocatable executable.
+  Default:       False
+
+flag lua53
+  Description:   Embed Lua 5.3 instead of 5.4.
+  Default:       False
+
+flag trypandoc
+  Description:   Build trypandoc cgi executable.
+  Default:       False
+
+common common-options
+  default-language: Haskell2010
+  build-depends:    base         >= 4.12 && < 5
+  ghc-options:      -Wall -fno-warn-unused-do-bind
+                    -Wincomplete-record-updates
+                    -Wnoncanonical-monad-instances
+                    -Wcpp-undef
+                    -Wincomplete-uni-patterns
+                    -Widentities
+                    -Wpartial-fields
+                    -Wmissing-signatures
+                    -fhide-source-paths
+                    -- -Wmissing-export-lists
+
+  if impl(ghc >= 8.10)
+    ghc-options:    -Wunused-packages
+
+  if impl(ghc >= 9.0)
+    ghc-options:    -Winvalid-haddock
+
+  if os(windows)
+    cpp-options:      -D_WINDOWS
+
+common common-executable
+  import:           common-options
+  build-depends:    pandoc
+  ghc-options:      -rtsopts -with-rtsopts=-A8m -threaded
+
+
+library
+  import:        common-options
+  build-depends: Glob                  >= 0.7      && < 0.11,
+                 JuicyPixels           >= 3.1.6.1  && < 3.4,
+                 SHA                   >= 1.6      && < 1.7,
+                 aeson                 >= 0.7      && < 2.1,
+                 aeson-pretty          >= 0.8.9    && < 0.9,
+                 array                 >= 0.5      && < 0.6,
+                 attoparsec            >= 0.12     && < 0.15,
+                 base64-bytestring     >= 0.1      && < 1.3,
+                 binary                >= 0.7      && < 0.11,
+                 blaze-html            >= 0.9      && < 0.10,
+                 blaze-markup          >= 0.8      && < 0.9,
+                 bytestring            >= 0.9      && < 0.12,
+                 case-insensitive      >= 1.2      && < 1.3,
+                 citeproc              >= 0.7      && < 0.8,
+                 commonmark            >= 0.2.2    && < 0.3,
+                 commonmark-extensions >= 0.2.3.1  && < 0.3,
+                 commonmark-pandoc     >= 0.2.1.2  && < 0.3,
+                 connection            >= 0.3.1,
+                 containers            >= 0.6.0.1  && < 0.7,
+                 data-default          >= 0.4      && < 0.8,
+                 deepseq               >= 1.3      && < 1.5,
+                 directory             >= 1.2.3    && < 1.4,
+                 doclayout             >= 0.4      && < 0.5,
+                 doctemplates          >= 0.10     && < 0.11,
+                 emojis                >= 0.1      && < 0.2,
+                 exceptions            >= 0.8      && < 0.11,
+                 file-embed            >= 0.0      && < 0.1,
+                 filepath              >= 1.1      && < 1.5,
+                 haddock-library       >= 1.10     && < 1.11,
+                 hslua-module-doclayout>= 1.0.4    && < 1.1,
+                 hslua-module-path     >= 1.0      && < 1.1,
+                 hslua-module-system   >= 1.0      && < 1.1,
+                 hslua-module-text     >= 1.0      && < 1.1,
+                 hslua-module-version  >= 1.0      && < 1.1,
+                 http-client           >= 0.4.30   && < 0.8,
+                 http-client-tls       >= 0.2.4    && < 0.4,
+                 http-types            >= 0.8      && < 0.13,
+                 ipynb                 >= 0.2      && < 0.3,
+                 jira-wiki-markup      >= 1.4      && < 1.5,
+                 lpeg                  >= 1.0.1    && < 1.1,
+                 mtl                   >= 2.2      && < 2.3,
+                 network               >= 2.6,
+                 network-uri           >= 2.6      && < 2.8,
+                 pandoc-lua-marshal    >= 0.1.5    && < 0.2,
+                 pandoc-types          >= 1.22.2   && < 1.23,
+                 parsec                >= 3.1      && < 3.2,
+                 pretty                >= 1.1      && < 1.2,
+                 pretty-show           >= 1.10     && < 1.11,
+                 process               >= 1.2.3    && < 1.7,
+                 random                >= 1        && < 1.3,
+                 safe                  >= 0.3.18   && < 0.4,
+                 scientific            >= 0.3      && < 0.4,
+                 skylighting           >= 0.12.3   && < 0.13,
+                 skylighting-core      >= 0.12.3   && < 0.13,
+                 split                 >= 0.2      && < 0.3,
+                 syb                   >= 0.1      && < 0.8,
+                 tagsoup               >= 0.14.6   && < 0.15,
+                 temporary             >= 1.1      && < 1.4,
+                 texmath               >= 0.12.5   && < 0.12.6,
+                 text                  >= 1.1.1.0  && < 2.1,
+                 text-conversions      >= 0.3      && < 0.4,
+                 time                  >= 1.5      && < 1.14,
+                 unicode-collation     >= 0.1.1    && < 0.2,
+                 unicode-transforms    >= 0.3      && < 0.5,
+                 xml                   >= 1.3.12   && < 1.4,
+                 xml-conduit           >= 1.9.1.1  && < 1.10,
+                 xml-types             >= 0.3      && < 0.4,
+                 yaml                  >= 0.11     && < 0.12,
+                 zip-archive           >= 0.2.3.4  && < 0.5,
+                 zlib                  >= 0.5      && < 0.7
+  if !os(windows)
+    build-depends:  unix >= 2.4 && < 2.8
+  if flag(lua53)
+    build-depends:  hslua >= 2.1 && < 2.2,
+                    hslua-aeson >= 2.1 && < 2.3
+  else
+    build-depends:  hslua >= 2.2 && < 2.3
+  if flag(embed_data_files)
+     cpp-options:   -DEMBED_DATA_FILES
+     other-modules: Text.Pandoc.Data
+  hs-source-dirs:  src
+
+  exposed-modules: Text.Pandoc,
+                   Text.Pandoc.App,
+                   Text.Pandoc.Options,
+                   Text.Pandoc.Extensions,
+                   Text.Pandoc.Shared,
+                   Text.Pandoc.Sources,
+                   Text.Pandoc.MediaBag,
+                   Text.Pandoc.Error,
+                   Text.Pandoc.Filter,
+                   Text.Pandoc.Readers,
+                   Text.Pandoc.Readers.HTML,
+                   Text.Pandoc.Readers.LaTeX,
+                   Text.Pandoc.Readers.Markdown,
+                   Text.Pandoc.Readers.CommonMark,
+                   Text.Pandoc.Readers.Creole,
+                   Text.Pandoc.Readers.BibTeX,
+                   Text.Pandoc.Readers.EndNote,
+                   Text.Pandoc.Readers.RIS,
+                   Text.Pandoc.Readers.CslJson,
+                   Text.Pandoc.Readers.MediaWiki,
+                   Text.Pandoc.Readers.Vimwiki,
+                   Text.Pandoc.Readers.RST,
+                   Text.Pandoc.Readers.Org,
+                   Text.Pandoc.Readers.DocBook,
+                   Text.Pandoc.Readers.JATS,
+                   Text.Pandoc.Readers.Jira,
+                   Text.Pandoc.Readers.OPML,
+                   Text.Pandoc.Readers.Textile,
+                   Text.Pandoc.Readers.Native,
+                   Text.Pandoc.Readers.Haddock,
+                   Text.Pandoc.Readers.TWiki,
+                   Text.Pandoc.Readers.TikiWiki,
+                   Text.Pandoc.Readers.Txt2Tags,
+                   Text.Pandoc.Readers.Docx,
+                   Text.Pandoc.Readers.Odt,
+                   Text.Pandoc.Readers.EPUB,
+                   Text.Pandoc.Readers.Muse,
+                   Text.Pandoc.Readers.Man,
+                   Text.Pandoc.Readers.FB2,
+                   Text.Pandoc.Readers.DokuWiki,
+                   Text.Pandoc.Readers.Ipynb,
+                   Text.Pandoc.Readers.CSV,
+                   Text.Pandoc.Readers.RTF,
+                   Text.Pandoc.Readers.Custom,
+                   Text.Pandoc.Writers,
+                   Text.Pandoc.Writers.Native,
+                   Text.Pandoc.Writers.Docbook,
+                   Text.Pandoc.Writers.JATS,
+                   Text.Pandoc.Writers.OPML,
+                   Text.Pandoc.Writers.HTML,
+                   Text.Pandoc.Writers.Ipynb,
+                   Text.Pandoc.Writers.ICML,
+                   Text.Pandoc.Writers.Jira,
+                   Text.Pandoc.Writers.LaTeX,
+                   Text.Pandoc.Writers.ConTeXt,
+                   Text.Pandoc.Writers.OpenDocument,
+                   Text.Pandoc.Writers.Texinfo,
+                   Text.Pandoc.Writers.Man,
+                   Text.Pandoc.Writers.Ms,
+                   Text.Pandoc.Writers.Markdown,
+                   Text.Pandoc.Writers.CommonMark,
+                   Text.Pandoc.Writers.Haddock,
+                   Text.Pandoc.Writers.RST,
+                   Text.Pandoc.Writers.Org,
+                   Text.Pandoc.Writers.AsciiDoc,
+                   Text.Pandoc.Writers.Custom,
+                   Text.Pandoc.Writers.Textile,
+                   Text.Pandoc.Writers.MediaWiki,
+                   Text.Pandoc.Writers.DokuWiki,
+                   Text.Pandoc.Writers.XWiki,
+                   Text.Pandoc.Writers.ZimWiki,
+                   Text.Pandoc.Writers.RTF,
+                   Text.Pandoc.Writers.ODT,
+                   Text.Pandoc.Writers.Docx,
+                   Text.Pandoc.Writers.Powerpoint,
+                   Text.Pandoc.Writers.EPUB,
+                   Text.Pandoc.Writers.FB2,
+                   Text.Pandoc.Writers.TEI,
+                   Text.Pandoc.Writers.Muse,
+                   Text.Pandoc.Writers.CslJson,
+                   Text.Pandoc.Writers.Math,
+                   Text.Pandoc.Writers.Shared,
+                   Text.Pandoc.Writers.OOXML,
+                   Text.Pandoc.Writers.AnnotatedTable,
+                   Text.Pandoc.Writers.BibTeX,
+                   Text.Pandoc.Lua,
+                   Text.Pandoc.PDF,
+                   Text.Pandoc.UTF8,
+                   Text.Pandoc.Templates,
+                   Text.Pandoc.XML,
+                   Text.Pandoc.SelfContained,
+                   Text.Pandoc.Highlighting,
+                   Text.Pandoc.Logging,
+                   Text.Pandoc.Process,
+                   Text.Pandoc.MIME,
+                   Text.Pandoc.Parsing,
+                   Text.Pandoc.Asciify,
+                   Text.Pandoc.Emoji,
+                   Text.Pandoc.ImageSize,
+                   Text.Pandoc.Class,
+                   Text.Pandoc.Citeproc
+  other-modules:   Text.Pandoc.App.CommandLineOptions,
+                   Text.Pandoc.App.FormatHeuristics,
+                   Text.Pandoc.App.Opt,
+                   Text.Pandoc.App.OutputSettings,
+                   Text.Pandoc.Class.CommonState,
+                   Text.Pandoc.Class.IO,
+                   Text.Pandoc.Class.PandocMonad,
+                   Text.Pandoc.Class.PandocIO,
+                   Text.Pandoc.Class.PandocPure,
+                   Text.Pandoc.Class.Sandbox,
+                   Text.Pandoc.Filter.Environment,
+                   Text.Pandoc.Filter.JSON,
+                   Text.Pandoc.Filter.Lua,
+                   Text.Pandoc.Filter.Path,
+                   Text.Pandoc.Parsing.Capabilities,
+                   Text.Pandoc.Parsing.Citations,
+                   Text.Pandoc.Parsing.General,
+                   Text.Pandoc.Parsing.GridTable,
+                   Text.Pandoc.Parsing.Lists,
+                   Text.Pandoc.Parsing.Math,
+                   Text.Pandoc.Parsing.Smart,
+                   Text.Pandoc.Parsing.State,
+                   Text.Pandoc.Parsing.Types,
+                   Text.Pandoc.Readers.Docx.Lists,
+                   Text.Pandoc.Readers.Docx.Combine,
+                   Text.Pandoc.Readers.Docx.Parse,
+                   Text.Pandoc.Readers.Docx.Parse.Styles,
+                   Text.Pandoc.Readers.Docx.Util,
+                   Text.Pandoc.Readers.Docx.Fields,
+                   Text.Pandoc.Readers.HTML.Parsing,
+                   Text.Pandoc.Readers.HTML.Table,
+                   Text.Pandoc.Readers.HTML.TagCategories,
+                   Text.Pandoc.Readers.HTML.Types,
+                   Text.Pandoc.Readers.LaTeX.Inline,
+                   Text.Pandoc.Readers.LaTeX.Citation,
+                   Text.Pandoc.Readers.LaTeX.Lang,
+                   Text.Pandoc.Readers.LaTeX.Macro,
+                   Text.Pandoc.Readers.LaTeX.Math,
+                   Text.Pandoc.Readers.LaTeX.Parsing,
+                   Text.Pandoc.Readers.LaTeX.SIunitx,
+                   Text.Pandoc.Readers.LaTeX.Table,
+                   Text.Pandoc.Readers.LaTeX.Types,
+                   Text.Pandoc.Readers.Odt.Base,
+                   Text.Pandoc.Readers.Odt.Namespaces,
+                   Text.Pandoc.Readers.Odt.StyleReader,
+                   Text.Pandoc.Readers.Odt.ContentReader,
+                   Text.Pandoc.Readers.Odt.Generic.Fallible,
+                   Text.Pandoc.Readers.Odt.Generic.SetMap,
+                   Text.Pandoc.Readers.Odt.Generic.Utils,
+                   Text.Pandoc.Readers.Odt.Generic.Namespaces,
+                   Text.Pandoc.Readers.Odt.Generic.XMLConverter,
+                   Text.Pandoc.Readers.Odt.Arrows.State,
+                   Text.Pandoc.Readers.Odt.Arrows.Utils,
+                   Text.Pandoc.Readers.Org.BlockStarts,
+                   Text.Pandoc.Readers.Org.Blocks,
+                   Text.Pandoc.Readers.Org.DocumentTree,
+                   Text.Pandoc.Readers.Org.ExportSettings,
+                   Text.Pandoc.Readers.Org.Inlines,
+                   Text.Pandoc.Readers.Org.Meta,
+                   Text.Pandoc.Readers.Org.ParserState,
+                   Text.Pandoc.Readers.Org.Parsing,
+                   Text.Pandoc.Readers.Org.Shared,
+                   Text.Pandoc.Readers.Metadata,
+                   Text.Pandoc.Readers.Roff,
+                   Text.Pandoc.Writers.Docx.StyleMap,
+                   Text.Pandoc.Writers.Docx.Table,
+                   Text.Pandoc.Writers.Docx.Types,
+                   Text.Pandoc.Writers.GridTable
+                   Text.Pandoc.Writers.JATS.References,
+                   Text.Pandoc.Writers.JATS.Table,
+                   Text.Pandoc.Writers.JATS.Types,
+                   Text.Pandoc.Writers.LaTeX.Caption,
+                   Text.Pandoc.Writers.LaTeX.Notes,
+                   Text.Pandoc.Writers.LaTeX.Table,
+                   Text.Pandoc.Writers.LaTeX.Lang,
+                   Text.Pandoc.Writers.LaTeX.Types,
+                   Text.Pandoc.Writers.LaTeX.Citation,
+                   Text.Pandoc.Writers.LaTeX.Util,
+                   Text.Pandoc.Writers.Markdown.Table,
+                   Text.Pandoc.Writers.Markdown.Types,
+                   Text.Pandoc.Writers.Markdown.Inline,
+                   Text.Pandoc.Writers.Roff,
+                   Text.Pandoc.Writers.Blaze,
+                   Text.Pandoc.Writers.Powerpoint.Presentation,
+                   Text.Pandoc.Writers.Powerpoint.Output,
+                   Text.Pandoc.Lua.ErrorConversion,
+                   Text.Pandoc.Lua.Filter,
+                   Text.Pandoc.Lua.Global,
+                   Text.Pandoc.Lua.Init,
+                   Text.Pandoc.Lua.Marshal.CommonState,
+                   Text.Pandoc.Lua.Marshal.Context,
+                   Text.Pandoc.Lua.Marshal.PandocError,
+                   Text.Pandoc.Lua.Marshal.ReaderOptions,
+                   Text.Pandoc.Lua.Marshal.Reference,
+                   Text.Pandoc.Lua.Marshal.Sources,
+                   Text.Pandoc.Lua.Marshal.Template,
+                   Text.Pandoc.Lua.Marshal.WriterOptions,
+                   Text.Pandoc.Lua.Module.MediaBag,
+                   Text.Pandoc.Lua.Module.Pandoc,
+                   Text.Pandoc.Lua.Module.System,
+                   Text.Pandoc.Lua.Module.Template,
+                   Text.Pandoc.Lua.Module.Types,
+                   Text.Pandoc.Lua.Module.Utils,
+                   Text.Pandoc.Lua.Orphans,
+                   Text.Pandoc.Lua.Packages,
+                   Text.Pandoc.Lua.PandocLua,
+                   Text.Pandoc.Lua.Writer.Classic,
+                   Text.Pandoc.XML.Light,
+                   Text.Pandoc.XML.Light.Types,
+                   Text.Pandoc.XML.Light.Proc,
+                   Text.Pandoc.XML.Light.Output,
+                   Text.Pandoc.Network.HTTP,
+                   Text.Pandoc.CSS,
+                   Text.Pandoc.CSV,
+                   Text.Pandoc.RoffChar,
+                   Text.Pandoc.UUID,
+                   Text.Pandoc.Translations,
+                   Text.Pandoc.Slides,
+                   Text.Pandoc.Image,
+                   Text.Pandoc.Citeproc.BibTeX,
+                   Text.Pandoc.Citeproc.CslJson,
+                   Text.Pandoc.Citeproc.Data,
+                   Text.Pandoc.Citeproc.Locator,
+                   Text.Pandoc.Citeproc.MetaValue,
+                   Text.Pandoc.Citeproc.Util,
+                   Paths_pandoc
+  autogen-modules: Paths_pandoc
+  buildable:       True
+
+executable pandoc
+  import:          common-executable
+  hs-source-dirs:  app
+  main-is:         pandoc.hs
+  buildable:       True
+  other-modules:   Paths_pandoc
+
+executable trypandoc
+  import:          common-executable
+  main-is:         trypandoc.hs
+  hs-source-dirs:  trypandoc
+  if flag(trypandoc)
+    build-depends: aeson,
+                   http-types,
+                   text,
+                   wai >= 0.3,
+                   wai-extra >= 3.0.24
+    buildable:     True
+  else
+    buildable:     False
+
+test-suite test-pandoc
+  import:         common-executable
+  type:           exitcode-stdio-1.0
+  main-is:        test-pandoc.hs
+  hs-source-dirs: test
+  build-depends:  pandoc,
+                  Diff              >= 0.2     && < 0.5,
+                  Glob              >= 0.7     && < 0.11,
+                  bytestring        >= 0.9     && < 0.12,
+                  containers        >= 0.4.2.1 && < 0.7,
+                  directory         >= 1.2.3   && < 1.4,
+                  doctemplates      >= 0.10    && < 0.11,
+                  exceptions        >= 0.8     && < 0.11,
+                  filepath          >= 1.1     && < 1.5,
+                  hslua             >= 2.1     && < 2.3,
+                  mtl               >= 2.2     && < 2.3,
+                  pandoc-types      >= 1.22.2  && < 1.23,
+                  process           >= 1.2.3   && < 1.7,
+                  tasty             >= 0.11    && < 1.5,
+                  tasty-golden      >= 2.3     && < 2.4,
+                  tasty-hunit       >= 0.9     && < 0.11,
+                  tasty-lua         >= 1.0     && < 1.1,
+                  tasty-quickcheck  >= 0.8     && < 0.11,
+                  text              >= 1.1.1.0 && < 2.1,
+                  time              >= 1.5     && < 1.14,
+                  xml               >= 1.3.12  && < 1.4,
+                  zip-archive       >= 0.2.3.4 && < 0.5
+  other-modules:  Tests.Old
+                  Tests.Command
+                  Tests.Helpers
+                  Tests.Lua
+                  Tests.Lua.Module
+                  Tests.Shared
+                  Tests.Readers.LaTeX
+                  Tests.Readers.HTML
+                  Tests.Readers.JATS
+                  Tests.Readers.Jira
+                  Tests.Readers.Markdown
+                  Tests.Readers.Org
+                  Tests.Readers.Org.Block
+                  Tests.Readers.Org.Block.CodeBlock
+                  Tests.Readers.Org.Block.Figure
+                  Tests.Readers.Org.Block.Header
+                  Tests.Readers.Org.Block.List
+                  Tests.Readers.Org.Block.Table
+                  Tests.Readers.Org.Directive
+                  Tests.Readers.Org.Inline
+                  Tests.Readers.Org.Inline.Citation
+                  Tests.Readers.Org.Inline.Note
+                  Tests.Readers.Org.Inline.Smart
+                  Tests.Readers.Org.Meta
+                  Tests.Readers.Org.Shared
+                  Tests.Readers.RST
+                  Tests.Readers.RTF
+                  Tests.Readers.Docx
+                  Tests.Readers.Odt
+                  Tests.Readers.Txt2Tags
+                  Tests.Readers.EPUB
+                  Tests.Readers.Muse
+                  Tests.Readers.Creole
+                  Tests.Readers.Man
+                  Tests.Readers.FB2
+                  Tests.Readers.DokuWiki
+                  Tests.Writers.Native
+                  Tests.Writers.ConTeXt
+                  Tests.Writers.Docbook
+                  Tests.Writers.HTML
+                  Tests.Writers.JATS
+                  Tests.Writers.Jira
+                  Tests.Writers.Markdown
+                  Tests.Writers.Org
+                  Tests.Writers.Plain
+                  Tests.Writers.AsciiDoc
+                  Tests.Writers.LaTeX
+                  Tests.Writers.Docx
+                  Tests.Writers.RST
+                  Tests.Writers.TEI
+                  Tests.Writers.Markua
+                  Tests.Writers.Muse
+                  Tests.Writers.FB2
+                  Tests.Writers.Powerpoint
+                  Tests.Writers.OOXML
+                  Tests.Writers.Ms
+                  Tests.Writers.AnnotatedTable
+
+benchmark benchmark-pandoc
+  import:          common-executable
+  type:            exitcode-stdio-1.0
+  main-is:         benchmark-pandoc.hs
+  hs-source-dirs:  benchmark
+  build-depends:   bytestring,
+                   tasty-bench >= 0.2     && <= 0.4,
+                   mtl         >= 2.2     && < 2.3,
+                   text        >= 1.1.1.0 && < 2.1,
+                   deepseq
+  -- we increase heap size to avoid benchmarking garbage collection:
+  ghc-options:     -rtsopts -with-rtsopts=-A8m -threaded
diff --git a/test/golden-test-cases/pandoc.nix.golden b/test/golden-test-cases/pandoc.nix.golden
new file mode 100644
--- /dev/null
+++ b/test/golden-test-cases/pandoc.nix.golden
@@ -0,0 +1,58 @@
+{ mkDerivation, aeson, aeson-pretty, array, attoparsec, base
+, base64-bytestring, binary, blaze-html, blaze-markup, bytestring
+, case-insensitive, citeproc, commonmark, commonmark-extensions
+, commonmark-pandoc, connection, containers, data-default, deepseq
+, Diff, directory, doclayout, doctemplates, emojis, exceptions
+, file-embed, filepath, Glob, haddock-library, hslua
+, hslua-module-doclayout, hslua-module-path, hslua-module-system
+, hslua-module-text, hslua-module-version, http-client
+, http-client-tls, http-types, ipynb, jira-wiki-markup, JuicyPixels
+, lib, lpeg, mtl, network, network-uri, pandoc-lua-marshal
+, pandoc-types, parsec, pretty, pretty-show, process, random, safe
+, scientific, SHA, skylighting, skylighting-core, split, syb
+, tagsoup, tasty, tasty-bench, tasty-golden, tasty-hunit, tasty-lua
+, tasty-quickcheck, temporary, texmath, text, text-conversions
+, time, unicode-collation, unicode-transforms, unix, xml
+, xml-conduit, xml-types, yaml, zip-archive, zlib
+}:
+mkDerivation {
+  pname = "pandoc";
+  version = "2.18";
+  sha256 = "deadbeef";
+  configureFlags = [ "-f-trypandoc" ];
+  isLibrary = true;
+  isExecutable = true;
+  enableSeparateDataOutput = true;
+  libraryHaskellDepends = [
+    aeson aeson-pretty array attoparsec base base64-bytestring binary
+    blaze-html blaze-markup bytestring case-insensitive citeproc
+    commonmark commonmark-extensions commonmark-pandoc connection
+    containers data-default deepseq directory doclayout doctemplates
+    emojis exceptions file-embed filepath Glob haddock-library hslua
+    hslua-module-doclayout hslua-module-path hslua-module-system
+    hslua-module-text hslua-module-version http-client http-client-tls
+    http-types ipynb jira-wiki-markup JuicyPixels lpeg mtl network
+    network-uri pandoc-lua-marshal pandoc-types parsec pretty
+    pretty-show process random safe scientific SHA skylighting
+    skylighting-core split syb tagsoup temporary texmath text
+    text-conversions time unicode-collation unicode-transforms unix xml
+    xml-conduit xml-types yaml zip-archive zlib
+  ];
+  executableHaskellDepends = [ base ];
+  testHaskellDepends = [
+    base bytestring containers Diff directory doctemplates exceptions
+    filepath Glob hslua mtl pandoc-types process tasty tasty-golden
+    tasty-hunit tasty-lua tasty-quickcheck text time xml zip-archive
+  ];
+  benchmarkHaskellDepends = [
+    base bytestring deepseq mtl tasty-bench text
+  ];
+  postInstall = ''
+    mkdir -p $out/share/man/man1
+    mv "man/"*.1 $out/share/man/man1/
+  '';
+  homepage = "https://pandoc.org";
+  description = "Conversion between markup formats";
+  license = lib.licenses.gpl2Plus;
+  mainProgram = "pandoc";
+}
diff --git a/test/golden-test-cases/persistent-mysql-haskell.nix.golden b/test/golden-test-cases/persistent-mysql-haskell.nix.golden
--- a/test/golden-test-cases/persistent-mysql-haskell.nix.golden
+++ b/test/golden-test-cases/persistent-mysql-haskell.nix.golden
@@ -20,4 +20,5 @@
   homepage = "http://www.yesodweb.com/book/persistent";
   description = "A pure haskell backend for the persistent library using MySQL database server";
   license = lib.licenses.mit;
+  mainProgram = "persistent-mysql-haskell-example";
 }
diff --git a/test/golden-test-cases/profiterole.nix.golden b/test/golden-test-cases/profiterole.nix.golden
--- a/test/golden-test-cases/profiterole.nix.golden
+++ b/test/golden-test-cases/profiterole.nix.golden
@@ -14,4 +14,5 @@
   homepage = "https://github.com/ndmitchell/profiterole#readme";
   description = "Restructure GHC profile reports";
   license = lib.licenses.bsd3;
+  mainProgram = "profiterole";
 }
diff --git a/test/golden-test-cases/rasterific-svg.nix.golden b/test/golden-test-cases/rasterific-svg.nix.golden
--- a/test/golden-test-cases/rasterific-svg.nix.golden
+++ b/test/golden-test-cases/rasterific-svg.nix.golden
@@ -20,4 +20,5 @@
   ];
   description = "SVG renderer based on Rasterific";
   license = lib.licenses.bsd3;
+  mainProgram = "svgrender";
 }
diff --git a/test/golden-test-cases/swagger.nix.golden b/test/golden-test-cases/swagger.nix.golden
--- a/test/golden-test-cases/swagger.nix.golden
+++ b/test/golden-test-cases/swagger.nix.golden
@@ -11,5 +11,4 @@
   testHaskellDepends = [ aeson base bytestring tasty tasty-hunit ];
   description = "Implementation of swagger data model";
   license = "unknown";
-  hydraPlatforms = lib.platforms.none;
 }
diff --git a/test/golden-test-cases/taggy.nix.golden b/test/golden-test-cases/taggy.nix.golden
--- a/test/golden-test-cases/taggy.nix.golden
+++ b/test/golden-test-cases/taggy.nix.golden
@@ -24,4 +24,5 @@
   homepage = "http://github.com/alpmestan/taggy";
   description = "Efficient and simple HTML/XML parsing library";
   license = lib.licenses.bsd3;
+  mainProgram = "taggy";
 }
diff --git a/test/golden-test-cases/turtle-options.nix.golden b/test/golden-test-cases/turtle-options.nix.golden
--- a/test/golden-test-cases/turtle-options.nix.golden
+++ b/test/golden-test-cases/turtle-options.nix.golden
@@ -13,4 +13,5 @@
   homepage = "https://github.com/elaye/turtle-options#readme";
   description = "Collection of command line options and parsers for these options";
   license = lib.licenses.bsd3;
+  mainProgram = "example";
 }
diff --git a/test/golden-test-cases/unlit.nix.golden b/test/golden-test-cases/unlit.nix.golden
--- a/test/golden-test-cases/unlit.nix.golden
+++ b/test/golden-test-cases/unlit.nix.golden
@@ -9,4 +9,5 @@
   executableHaskellDepends = [ base directory text ];
   description = "Tool to convert literate code between styles or to code";
   license = lib.licenses.bsd3;
+  mainProgram = "unlit";
 }
diff --git a/test/golden-test-cases/wai-middleware-auth.nix.golden b/test/golden-test-cases/wai-middleware-auth.nix.golden
--- a/test/golden-test-cases/wai-middleware-auth.nix.golden
+++ b/test/golden-test-cases/wai-middleware-auth.nix.golden
@@ -25,4 +25,5 @@
   ];
   description = "Authentication middleware that secures WAI application";
   license = lib.licenses.mit;
+  mainProgram = "wai-auth";
 }
